Merge pull request #381 from Asvarox/tailwind-migration #1639
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
quick-checks: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: './.github/templates/setup-node' | |
- run: pnpm npm-run-all --continue-on-error prettier-check lint types-check test build-storybook unimported | |
e2e-tests-run: | |
strategy: | |
fail-fast: false | |
matrix: | |
browser: [ 'chromium', 'firefox' ] | |
shardIndex: [ 1, 2 ] | |
shardTotal: [ 2 ] | |
runs-on: ubuntu-latest | |
env: | |
VITE_APP_SENTRY_DSN_URL: ${{ secrets.VITE_APP_SENTRY_DSN_URL }} | |
VITE_APP_POSTHOG_KEY: ${{ secrets.VITE_APP_POSTHOG_KEY }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: './.github/templates/setup-node' | |
- name: Build app | |
run: | | |
npx playwright install chromium | |
pnpm build | |
- name: Run E2E tests | |
uses: './.github/templates/run-playwright' | |
with: | |
project: '${{ matrix.browser }}' | |
packagescript: 'e2e' | |
shard: '${{ matrix.shardIndex }}' | |
shardTotal: '${{ matrix.shardTotal }}' | |
e2e-tests-add-summary: | |
runs-on: ubuntu-latest | |
if: ${{ failure() }} | |
needs: e2e-tests-run | |
steps: | |
- uses: actions/github-script@v7 | |
with: | |
script: | | |
core.summary.addRaw(` | |
# E2E tests reports | |
| Name | Result | | |
| ----------------------- | - | | |
| **URL**: | https://${{ github.run_id }}.allkaraoke-party-tests-results.pages.dev | | |
` | |
).write(); | |
ct-tests-run: | |
permissions: | |
contents: write # https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#usage | |
pull-requests: write # allows commenting on a PR | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: './.github/templates/setup-node' | |
- name: Run CT tests | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
uses: './.github/templates/run-playwright' | |
with: | |
packagescript: 'test-ct' | |
- name: Run CT tests and update snapshots | |
if: github.ref != 'refs/heads/master' | |
uses: './.github/templates/run-playwright' | |
with: | |
packagescript: 'test-ct -u' | |
- name: Auto commit updated snapshots | |
id: auto-commit-action | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
if: github.ref != 'refs/heads/master' | |
with: | |
commit_message: '[ci-skip] chore: update visual regression snapshots' | |
commit_options: '--no-verify' | |
- name: "Comment on PR to request a review of visual changes" | |
if: steps.auto-commit-action.outputs.changes_detected == 'true' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.pulls.createReview({ // https://octokit.github.io/rest.js/v20#pulls | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number, | |
body: 'Changes detected in visual regression tests. Please review.', | |
event: 'COMMENT', | |
}) | |
deploy: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
needs: ['e2e-tests-run', 'ct-tests-run', 'quick-checks'] | |
environment: | |
name: production | |
url: https://allkaraoke.party/ | |
env: | |
VITE_APP_SENTRY_DSN_URL: ${{ secrets.VITE_APP_SENTRY_DSN_URL }} | |
VITE_APP_POSTHOG_KEY: ${{ secrets.VITE_APP_POSTHOG_KEY }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 30 # needed for Sentry to get list of commits released | |
- name: Setup Node | |
uses: './.github/templates/setup-node' | |
- run: npx playwright install chromium | |
- run: pnpm build | |
- name: Deploy 🚀 | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
folder: build # The folder the action should deploy. | |
- name: Create Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
with: | |
environment: production | |
sourcemaps: './build' | |
- name: Add Deployment PostHog Annotation | |
run: | | |
curl \ | |
-H 'Content-Type: application/json' \ | |
-H "Authorization: Bearer ${{ secrets.POSTHOG_PAT_KEY }}" \ | |
-d '{"content":"Deployment https://github.com/Asvarox/allkaraoke/actions/runs/${{ github.run_id }}","date_marker":"'$(date --iso-8601=seconds)'","scope":"project","creation_type":"GIT"}' \ | |
https://eu.posthog.com/api/projects/281/annotations/ | |
env: | |
POSTHOG_PAT_KEY: ${{ secrets.POSTHOG_PAT_KEY }} | |
- name: "Start monitoring" | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GH_PAT_REPOS_WORKFLOW }} | |
script: | | |
github.rest.actions.updateRepoVariable({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: 'MONITORING_ATTEMPTS', | |
value: '4' | |
}); | |
github.rest.actions.enableWorkflow({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
workflow_id: 'monitor-posthog-events.yml', | |
}); | |
deploy-branch: | |
runs-on: ubuntu-latest | |
if: github.ref != 'refs/heads/master' | |
environment: | |
name: prs | |
url: https://allkaraoke.party/prs/${{ github.event.number }}/ | |
env: | |
VITE_APP_SENTRY_DSN_URL: ${{ secrets.VITE_APP_SENTRY_DSN_URL }} | |
VITE_APP_POSTHOG_KEY: ${{ secrets.VITE_APP_POSTHOG_KEY }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: './.github/templates/setup-node' | |
- run: npx playwright install chromium | |
- run: pnpm build --base /prs/${{ github.event.number }}/ && rm -rf build/songs | |
shell: bash | |
- name: Deploy PR 🚀 | |
uses: JamesIves/github-pages-deploy-action@v4 | |
continue-on-error: true | |
with: | |
folder: build # The folder the action should deploy. | |
target-folder: prs/${{ github.event.number }} # The folder the action should deploy to. | |
clean-exclude: | | |
!prs/${{ github.event.number }}/ |