add deploy workflow [skip ci]

This commit is contained in:
Nebel 2024-03-16 19:46:54 +09:00
parent e808fda003
commit 89e1b3f942
Signed by: nebel
GPG key ID: 79807D08C6EF6460
2 changed files with 33 additions and 3 deletions

21
.github/workflows/deploy.yml vendored Normal file
View file

@ -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 }}

View file

@ -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: