diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..b87d34d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,21 @@ +name: deploy +on: + workflow_dispatch: + schedule: + # 3月16日土曜日 20:00 (JST) は 3月16日土曜日 11:00 (UTC) + # https://time.is/compare/JST/UTC + # https://crontab.guru/#00_11_16_03_SAT + - cron: 00 11 16 3 SAT + push: + branches: main +jobs: + deploy: + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + timeout-minutes: 1 + steps: + - name: Deploy + run: curl -sSf -X POST "${DEPLOY_WEBHOOK_URL}" + env: + # https://developers.cloudflare.com/pages/platform/deploy-hooks + DEPLOY_WEBHOOK_URL: ${{ secrets.DEPLOY_WEBHOOK_URL }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b93b220..a9c6c03 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,9 @@ name: test -on: pull_request +on: + pull_request: + workflow_run: + workflows: deploy + types: completed jobs: test: strategy: @@ -19,11 +23,16 @@ jobs: run: npm ci - name: Install Playwright Browsers run: npx playwright install --with-deps - - name: Run tests + - if: github.ref_name != github.event.repository.default_branch + id: set_preview_env shell: bash - run: BASE_URL="https://$(echo "${HEAD_REF}" | sed s/[^_0-9a-z]/-/gi).jwk.pages.dev/" npm test + run: echo url="https://$(echo "${HEAD_REF}" | sed s/[^_0-9a-z]/-/gi).jwk.pages.dev/" >> "${GITHUB_OUTPUT}" env: HEAD_REF: ${{ github.head_ref }} + - name: Run tests in ${{ env.BASE_URL }} + run: npm test + env: + BASE_URL: ${{ github.ref_name == github.event.repository.default_branch && 'https://jwk.pages.dev/' || steps.set_preview_env.outputs.url }} - uses: actions/upload-artifact@v4 if: always() with: