Relay CI Failure #89
This file contains hidden or 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: Relay CI Failure | |
| on: | |
| workflow_run: | |
| workflows: ["CI", "Tests", "Build", "Test", "ci", "tests", "build"] | |
| types: [completed] | |
| jobs: | |
| relay: | |
| if: >- | |
| github.event.workflow_run.conclusion == 'failure' && | |
| github.event.workflow_run.event == 'pull_request' && | |
| github.event.workflow_run.pull_requests[0] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check kill switch | |
| id: guard | |
| env: | |
| GH_TOKEN: ${{ secrets.DISPATCH_TOKEN }} | |
| run: | | |
| PR_NUMBER="${{ github.event.workflow_run.pull_requests[0].number }}" | |
| LABELS=$(gh api repos/${{ github.repository }}/issues/${PR_NUMBER}/labels --jq '.[].name' 2>/dev/null || echo "") | |
| if echo "$LABELS" | grep -q "manual-review"; then | |
| echo "Kill switch active. Skipping." | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Dispatch to Ghost Ship | |
| if: steps.guard.outputs.skip != 'true' | |
| run: | | |
| set -e | |
| PR_NUMBER="${{ github.event.workflow_run.pull_requests[0].number }}" | |
| RUN_ID="${{ github.event.workflow_run.id }}" | |
| HTTP_CODE=$(curl -s -o /tmp/dispatch_response -w "%{http_code}" -X POST \ | |
| -H "Authorization: Bearer ${{ secrets.DISPATCH_TOKEN }}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "https://api.github.com/repos/${{ secrets.GHOST_SHIP_REPO }}/dispatches" \ | |
| -d "{ | |
| \"event_type\": \"ci-failure\", | |
| \"client_payload\": { | |
| \"repo\": \"${{ github.repository }}\", | |
| \"pr_number\": ${PR_NUMBER}, | |
| \"run_id\": ${RUN_ID} | |
| } | |
| }") | |
| if [ "$HTTP_CODE" -lt 200 ] || [ "$HTTP_CODE" -ge 300 ]; then | |
| echo "Dispatch failed with HTTP ${HTTP_CODE}:" | |
| cat /tmp/dispatch_response | |
| exit 1 | |
| fi | |
| echo "Dispatched ci-failure for PR #${PR_NUMBER}, run ${RUN_ID} (HTTP ${HTTP_CODE})" |