A local-first personal finance app
feat: trigger VRT updates via /update-vrt comment (#6380)
Matiss Janis Aboltins4ae85096cd3c
diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.ymlindex 51adc54e47..bdecd897d9 100644--- a/.github/workflows/e2e-test.yml+++ b/.github/workflows/e2e-test.yml@@ -149,5 +149,5 @@ jobs:issue_number: context.issue.number,owner: context.repo.owner,repo: context.repo.repo,- body: `VRT tests ❌ failed. [View the test report](${{ steps.playwright-report-vrt.outputs.artifact-url }}).`+ body: `VRT tests ❌ failed. [View the test report](${{ steps.playwright-report-vrt.outputs.artifact-url }}).\n\nTo update the VRT screenshots, comment \`/update-vrt\` on this PR.`});diff --git a/.github/workflows/vrt-update-generate.yml b/.github/workflows/vrt-update-generate.ymlindex c9f270e575..17b6fde1a7 100644--- a/.github/workflows/vrt-update-generate.yml+++ b/.github/workflows/vrt-update-generate.yml@@ -1,37 +1,47 @@name: VRT Update - Generate# SECURITY: This workflow runs in untrusted fork context with no write permissions.# It only generates VRT patch artifacts that are later applied by vrt-update-apply.yml+# Triggered by commenting "/update-vrt" on a pull request.on:- pull_request:- types: [opened, synchronize, reopened]- paths:- - "packages/**"- - "package.json"- - "yarn.lock"- - ".github/workflows/vrt-update-generate.yml"- - "!packages/sync-server/**" # Sync server changes don't affect the VRT- - "!packages/api/**" # API changes don't affect the VRT- - "!packages/ci-actions/**" # CI actions changes don't affect the VRT- - "!packages/docs/**" # Docs changes don't affect the VRT- - "!packages/eslint-plugin-actual/**" # Eslint plugin changes don't affect the VRT+ issue_comment:+ types: [created]permissions:contents: read+ pull-requests: readconcurrency:- group: ${{ github.workflow }}-${{ github.event.pull_request.number }}+ group: ${{ github.workflow }}-${{ github.event.issue.number }}cancel-in-progress: truejobs:generate-vrt-updates:name: Generate VRT Updatesruns-on: ubuntu-latest+ # Only run on PR comments containing /update-vrt+ if: >+ github.event.issue.pull_request &&+ startsWith(github.event.comment.body, '/update-vrt')container:image: mcr.microsoft.com/playwright:v1.56.0-jammysteps:+ - name: Get PR details+ id: pr+ uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0+ with:+ script: |+ const { data: pr } = await github.rest.pulls.get({+ owner: context.repo.owner,+ repo: context.repo.repo,+ pull_number: context.issue.number+ });+ core.setOutput('head_sha', pr.head.sha);+ core.setOutput('head_ref', pr.head.ref);+ core.setOutput('head_repo', pr.head.repo.full_name);+- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0with:- ref: ${{ github.event.pull_request.head.sha }}+ ref: ${{ steps.pr.outputs.head_sha }}- name: Set up environmentuses: ./.github/actions/setup@@ -44,7 +54,7 @@ jobs:- name: Wait for Netlify build to finishid: netlifyenv:- COMMIT_SHA: ${{ github.event.pull_request.head.sha }}+ COMMIT_SHA: ${{ steps.pr.outputs.head_sha }}GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}run: ./.github/actions/netlify-wait-for-build@@ -91,7 +101,7 @@ jobs:if: steps.create-patch.outputs.has_changes == 'true'uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0with:- name: vrt-patch-${{ github.event.pull_request.number }}+ name: vrt-patch-${{ github.event.issue.number }}path: vrt-update.patchretention-days: 5@@ -99,14 +109,14 @@ jobs:if: steps.create-patch.outputs.has_changes == 'true'run: |mkdir -p pr-metadata- echo "${{ github.event.pull_request.number }}" > pr-metadata/pr-number.txt- echo "${{ github.event.pull_request.head.ref }}" > pr-metadata/head-ref.txt- echo "${{ github.event.pull_request.head.repo.full_name }}" > pr-metadata/head-repo.txt+ echo "${{ github.event.issue.number }}" > pr-metadata/pr-number.txt+ echo "${{ steps.pr.outputs.head_ref }}" > pr-metadata/head-ref.txt+ echo "${{ steps.pr.outputs.head_repo }}" > pr-metadata/head-repo.txt- name: Upload PR metadataif: steps.create-patch.outputs.has_changes == 'true'uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0with:- name: vrt-metadata-${{ github.event.pull_request.number }}+ name: vrt-metadata-${{ github.event.issue.number }}path: pr-metadata/retention-days: 5diff --git a/upcoming-release-notes/6380.md b/upcoming-release-notes/6380.mdnew file mode 100644index 0000000000..b261938f5e--- /dev/null+++ b/upcoming-release-notes/6380.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [MatissJanis]+---++Trigger VRT update workflow only if '/update-vrt' comment is added