|
| 1 | +##################################### |
| 2 | +# DO NOT EDIT DIRECTLY. # |
| 3 | +# This file is managed by Terraform # |
| 4 | +##################################### |
| 5 | + |
| 6 | +name: "Code Freeze Bypass Status" |
| 7 | + |
| 8 | +on: |
| 9 | + pull_request_target: |
| 10 | + types: |
| 11 | + - labeled |
| 12 | + - unlabeled |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + pull-requests: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + update-status: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + env: |
| 22 | + BYPASS_LABEL: bypass-code-freeze |
| 23 | + steps: |
| 24 | + - name: Emit bypass status |
| 25 | + uses: actions/github-script@v7 |
| 26 | + with: |
| 27 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + script: | |
| 29 | + const action = context.payload.action; |
| 30 | + const label = context.payload.label?.name || ""; |
| 31 | + if (!["labeled", "unlabeled"].includes(action)) { |
| 32 | + core.info(`Unhandled action: ${action}`); |
| 33 | + return; |
| 34 | + } |
| 35 | + const owner = context.payload.repository.owner.login; |
| 36 | + const repo = context.payload.repository.name; |
| 37 | + const topicsResponse = await github.rest.repos.getAllTopics({ owner, repo }); |
| 38 | + const topics = topicsResponse.data.names || []; |
| 39 | + if (!topics.includes("code-freeze")) { |
| 40 | + core.info(`Repository ${owner}/${repo} is not marked with code-freeze topic; skipping enforcement.`); |
| 41 | + return; |
| 42 | + } |
| 43 | +
|
| 44 | + if (label !== process.env.BYPASS_LABEL) { |
| 45 | + core.setFailed( |
| 46 | + `Label '${label}' is not allowed while ${owner}/${repo} is in code freeze. Only '${process.env.BYPASS_LABEL}' may change.`, |
| 47 | + ); |
| 48 | + return; |
| 49 | + } |
| 50 | +
|
| 51 | + if (action === "labeled") { |
| 52 | + core.info("Bypass label applied; workflow passing."); |
| 53 | + return; |
| 54 | + } |
| 55 | +
|
| 56 | + core.setFailed("Bypass label removed; code freeze enforced."); |
0 commit comments