name: Record Snapshots on: # Triggered when a maintainer adds the "record-snapshots" label to a PR. pull_request: # zizmor: ignore[dangerous-triggers] types: [labeled] permissions: {} jobs: record-snapshots: name: Record Preview Snapshots runs-on: macos-26 timeout-minutes: 45 if: > github.event.label.name == 'record-snapshots' && github.event.pull_request.head.repo.full_name == github.repository permissions: contents: write pull-requests: write concurrency: group: record-snapshots-${{ github.event.pull_request.number }} cancel-in-progress: true steps: - name: Remove label if: github.event.label.name == 'record-snapshots' uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 #v1.3.0 with: labels: record-snapshots - name: Checkout PR uses: nschloe/action-cached-lfs-checkout@385a8ecc719e50b8c71af6ab01a624b486b7c3bc # v1.2.5 with: # Check out the PR head commit (not the base branch). ref: ${{ github.event.pull_request.head.sha }} persist-credentials: true - name: Setup environment run: source ci_scripts/ci_common.sh && setup_github_actions_environment - name: Run preview tests in recording mode run: swift run -q tools ci preview-tests --record - name: Commit and push updated snapshots run: | git config user.name "Element CI" git config user.email "ci@element.io" # Stage only snapshot changes. git add PreviewTests/Sources/__Snapshots__/ if git diff --cached --quiet; then echo "✅ No snapshot changes detected." else git commit -m "Record preview snapshots" git push origin HEAD:refs/heads/${GITHUB_EVENT_PULL_REQUEST_HEAD_REF} echo "✅ Snapshots recorded and pushed." fi env: GITHUB_EVENT_PULL_REQUEST_HEAD_REF: ${{ github.event.pull_request.head.ref }}