CI Failure Handler #64
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: CI Failure Handler | |
| # Watched workflows: | |
| # - TestFlight Build | |
| # - Internal Staging TestFlight Build | |
| # - Release App Store Version | |
| # - Submit App Store Review | |
| # - Backend Staging Deploy | |
| # - Promote Backend Production | |
| # - Backend Go tests | |
| # - Backend Python tests | |
| # - Deliver App Store Metadata | |
| # - Infrastructure Validation | |
| # - Evidence regression | |
| # - Backend PR | |
| # | |
| # Exclusion criteria: | |
| # - Gating-PR checks like `pr-build` are already enforced at merge and failures are surfaced to developers on the PR itself. | |
| # - The handler itself ("CI Failure Handler") cannot watch itself to avoid infinite loops. | |
| on: | |
| workflow_run: | |
| types: [completed] | |
| workflows: | |
| - "TestFlight Build" | |
| - "Internal Staging TestFlight Build" | |
| - "Release App Store Version" | |
| - "Submit App Store Review" | |
| - "Backend Staging Deploy" | |
| - "Promote Backend Production" | |
| - "Backend Go tests" | |
| - "Backend Python tests" | |
| - "Deliver App Store Metadata" | |
| - "Infrastructure Validation" | |
| - "Evidence regression" | |
| - "Backend PR" | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| jobs: | |
| create-linear-issue: | |
| if: github.event.workflow_run.conclusion == 'failure' || github.event.workflow_run.conclusion == 'success' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Create Linear issue for failed CI | |
| env: | |
| LINEAR_API_TOKEN: ${{ secrets.LINEAR_API_TOKEN }} | |
| LINEAR_TEAM_KEY: EPAC | |
| # Note: workflow_run runs in the default branch's context, but github.event.workflow_run.head_branch | |
| # correctly points to the branch that triggered the upstream workflow. | |
| WORKFLOW_NAME: ${{ github.event.workflow_run.name }} | |
| RUN_URL: ${{ github.event.workflow_run.html_url }} | |
| HEAD_SHA: ${{ github.event.workflow_run.head_sha }} | |
| BRANCH_NAME: ${{ github.event.workflow_run.head_branch }} | |
| CONCLUSION: ${{ github.event.workflow_run.conclusion }} | |
| REPOSITORY: ${{ github.repository }} | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: | | |
| python3 scripts/ci/ci_failure_to_linear.py \ | |
| --workflow-name "${WORKFLOW_NAME}" \ | |
| --run-url "${RUN_URL}" \ | |
| --head-sha "${HEAD_SHA}" \ | |
| --branch "${BRANCH_NAME}" \ | |
| --conclusion "${CONCLUSION}" \ | |
| --repo "${REPOSITORY}" \ | |
| --team-key "${LINEAR_TEAM_KEY}" |