|
6 | 6 | - main
|
7 | 7 | pull_request:
|
8 | 8 |
|
| 9 | +# Add concurrency group to cancel in-progress runs |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
9 | 14 | env:
|
10 | 15 | CARGO_TERM_COLOR: always
|
11 | 16 | RUST_VERSION: 1.80.1
|
|
71 | 76 | storybook:
|
72 | 77 | runs-on: ubuntu-22.04
|
73 | 78 | container:
|
74 |
| - image: ghcr.io/cartridge-gg/controller/storybook-env:sha-db7f70d |
| 79 | + image: ghcr.io/cartridge-gg/controller/storybook-env:sha-a808942 |
75 | 80 | permissions:
|
76 |
| - contents: "read" |
| 81 | + contents: "write" |
77 | 82 | id-token: "write"
|
78 | 83 | pull-requests: "write"
|
79 | 84 | steps:
|
@@ -171,6 +176,26 @@ jobs:
|
171 | 176 | echo "snapshot_failed=false" >> "$GITHUB_ENV"
|
172 | 177 | fi
|
173 | 178 |
|
| 179 | + # Add new steps after the check-diffs step |
| 180 | + - name: Configure Git |
| 181 | + if: env.snapshot_failed == 'true' |
| 182 | + run: | |
| 183 | + git config --global user.name 'github-actions[bot]' |
| 184 | + git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 185 | +
|
| 186 | + - name: Update and commit snapshots |
| 187 | + if: env.snapshot_failed == 'true' |
| 188 | + run: | |
| 189 | + # Run the update script |
| 190 | + pnpm test:storybook:update |
| 191 | +
|
| 192 | + # Stage and commit changes |
| 193 | + git add packages/*/__image_snapshots__/ |
| 194 | + git commit -m "chore: update storybook snapshots [skip ci]" |
| 195 | +
|
| 196 | + # Push to the PR branch |
| 197 | + git push origin HEAD:${{ github.head_ref }} |
| 198 | +
|
174 | 199 | # Upload diff images to GCP
|
175 | 200 | - uses: "google-github-actions/auth@v2"
|
176 | 201 | with:
|
@@ -271,11 +296,11 @@ jobs:
|
271 | 296 | body: comment
|
272 | 297 | });
|
273 | 298 |
|
274 |
| - # Fail the job if there were visual differences |
| 299 | + # Modify the final check step to not fail when snapshots are updated |
275 | 300 | - name: Check for failures
|
276 | 301 | if: always()
|
277 | 302 | run: |
|
278 | 303 | if [[ "${{ env.snapshot_failed }}" == "true" ]]; then
|
279 |
| - echo "Visual differences detected in Storybook tests" |
280 |
| - exit 1 |
| 304 | + echo "Visual differences detected in Storybook tests - snapshots have been updated automatically" |
| 305 | + exit 0 |
281 | 306 | fi
|
0 commit comments