Live test: skip when the Deploy run it follows deployed nothing
Deploy's gate skips a commit that is no longer main's tip; the Live test then has nothing new to test, so it ends with a notice instead of a green run against the older site. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014R3J2i3cD96PEceUzqjks8
1 file changed+15−0
modified.github/workflows/live-test.yml+15−0View file
| @@ -19,6 +19,8 @@ | ||
| 19 | 19 | |
| 20 | 20 | permissions: |
| 21 | 21 | contents: read |
| 22 | + # To see whether the Deploy run it follows deployed anything. | |
| 23 | + actions: read | |
| 22 | 24 | |
| 23 | 25 | concurrency: |
| 24 | 26 | group: live-test |
| @@ -40,7 +42,20 @@ | ||
| 40 | 42 | steps: |
| 41 | 43 | - name: Check the token |
| 42 | 44 | id: token |
| 45 | + env: | |
| 46 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| 47 | + DEPLOY_RUN: ${{ github.event.workflow_run.id }} | |
| 43 | 48 | run: | |
| 49 | + if [ "$GITHUB_EVENT_NAME" = workflow_run ]; then | |
| 50 | + # Deploy's gate skips a commit that is no longer main's tip (the newer commit's run deploys it): | |
| 51 | + # then nothing new is live, and this run would only test the site as it was. | |
| 52 | + deployed=$(curl -fsS "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/runs/$DEPLOY_RUN/jobs" -H "Authorization: Bearer $GH_TOKEN" | jq -r '[.jobs[] | select(.name == "Deploy to Cloudflare") | .conclusion][0] // "unknown"' || echo unknown) | |
| 53 | + if [ "$deployed" = skipped ]; then | |
| 54 | + echo "::notice::Deploy deployed nothing for $HEAD_SHA (main has moved on), so there is nothing new to test" | |
| 55 | + echo "skip=true" >> "$GITHUB_OUTPUT" | |
| 56 | + exit 0 | |
| 57 | + fi | |
| 58 | + fi | |
| 44 | 59 | if [ -z "$TOKEN" ]; then |
| 45 | 60 | # After a deploy of diffinery.com a missing token is an error: a green run would mean nothing was tested. |
| 46 | 61 | if [ "$GITHUB_EVENT_NAME" = workflow_run ]; then |