|
| 1 | +name: verify-attach |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: |
| 6 | + - verify-remote |
| 7 | + types: |
| 8 | + - completed |
| 9 | + |
| 10 | +permissions: |
| 11 | + actions: read |
| 12 | + contents: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + publish: |
| 16 | + name: Publish handed-off evidence |
| 17 | + if: >- |
| 18 | + github.event.workflow_run.event == 'workflow_dispatch' && |
| 19 | + github.event.workflow_run.path == '.github/workflows/verify-remote.yml' && |
| 20 | + github.event.workflow_run.head_repository.full_name == github.repository |
| 21 | + runs-on: ${{ vars.RUNNER_NORMAL || 'ubuntu-latest' }} |
| 22 | + timeout-minutes: 15 |
| 23 | + environment: verify-evidence |
| 24 | + concurrency: |
| 25 | + group: verify-attach-${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }} |
| 26 | + cancel-in-progress: false |
| 27 | + queue: max |
| 28 | + env: |
| 29 | + HAS_EVIDENCE_TOKEN: ${{ secrets.VERIFY_EVIDENCE_TOKEN != '' }} |
| 30 | + REPO: ${{ github.repository }} |
| 31 | + RUN_ID: ${{ github.event.workflow_run.id }} |
| 32 | + RUN_ACTOR: ${{ github.event.workflow_run.actor.login }} |
| 33 | + steps: |
| 34 | + - name: Say that no token is set |
| 35 | + if: env.HAS_EVIDENCE_TOKEN != 'true' |
| 36 | + run: echo "::notice title=verify-attach::The environment verify-evidence has no secret VERIFY_EVIDENCE_TOKEN, so no evidence is published." |
| 37 | + |
| 38 | + - name: Checkout the trusted script |
| 39 | + if: env.HAS_EVIDENCE_TOKEN == 'true' |
| 40 | + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 |
| 41 | + with: |
| 42 | + ref: ${{ github.sha }} |
| 43 | + sparse-checkout: scripts/verify-attach.mjs |
| 44 | + sparse-checkout-cone-mode: false |
| 45 | + persist-credentials: false |
| 46 | + |
| 47 | + - name: Set up Node |
| 48 | + if: env.HAS_EVIDENCE_TOKEN == 'true' |
| 49 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 50 | + with: |
| 51 | + node-version: 24 |
| 52 | + |
| 53 | + - name: Fetch and validate the evidence |
| 54 | + id: evidence |
| 55 | + if: env.HAS_EVIDENCE_TOKEN == 'true' |
| 56 | + env: |
| 57 | + GITHUB_TOKEN: ${{ github.token }} |
| 58 | + WORK: ${{ runner.temp }}/verify-attach |
| 59 | + RUN_EVENT: ${{ github.event.workflow_run.event }} |
| 60 | + RUN_PATH: ${{ github.event.workflow_run.path }} |
| 61 | + RUN_HEAD_REPO: ${{ github.event.workflow_run.head_repository.full_name }} |
| 62 | + run: node scripts/verify-attach.mjs fetch |
| 63 | + |
| 64 | + - name: Install a gh whose pr edit has --attach |
| 65 | + if: steps.evidence.outputs.found == 'true' |
| 66 | + env: |
| 67 | + GH_VERSION: '2.102.0' |
| 68 | + GH_SHA256: bb766f710eef8ede859c18578c72c327597cd4c8a85b06001b1f3843c6019386 |
| 69 | + run: | |
| 70 | + set -euo pipefail |
| 71 | + curl -fsSL --max-time 300 --retry 3 --retry-delay 2 -o "$RUNNER_TEMP/gh.tar.gz" "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz" |
| 72 | + echo "$GH_SHA256 $RUNNER_TEMP/gh.tar.gz" | sha256sum -c - |
| 73 | + tar -xzf "$RUNNER_TEMP/gh.tar.gz" -C "$RUNNER_TEMP" |
| 74 | + echo "$RUNNER_TEMP/gh_${GH_VERSION}_linux_amd64/bin" >> "$GITHUB_PATH" |
| 75 | +
|
| 76 | + - name: Put the evidence in the pull request description |
| 77 | + if: steps.evidence.outputs.found == 'true' |
| 78 | + env: |
| 79 | + GH_TOKEN: ${{ secrets.VERIFY_EVIDENCE_TOKEN }} |
| 80 | + WORK: ${{ runner.temp }}/verify-attach |
| 81 | + HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} |
| 82 | + HEAD_SHA: ${{ github.event.workflow_run.head_sha }} |
| 83 | + run: node scripts/verify-attach.mjs publish |
0 commit comments