ci: make reviewer Stage 0 clean and contained #6
Workflow file for this run
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: Copse review trigger | ||
|
Check warning on line 1 in .github/workflows/review-trigger.yml
|
||
| # A label event on an older pull request must still select trusted workflow code. | ||
| # `pull_request_target` provides that default-branch context, but this workflow | ||
| # deliberately never checks out or executes repository code. Its only privileged | ||
| # operation is dispatching the separate, permissionless ground workflow with PR | ||
| # metadata resolved from GitHub's API. | ||
| on: | ||
| pull_request_target: | ||
| types: [labeled] | ||
| permissions: {} | ||
| concurrency: | ||
| group: copse-review-trigger-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| dispatch: | ||
| name: Resolve and dispatch the labelled pull request | ||
| if: github.event.label.name == 'copse-review' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| permissions: | ||
| actions: write | ||
| pull-requests: read | ||
| steps: | ||
| - name: Resolve the current pull request and dispatch secret-free grounding | ||
| shell: bash | ||
| env: | ||
| DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} | ||
| GH_TOKEN: ${{ github.token }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| run: | | ||
| set -euo pipefail | ||
| IFS=$'\t' read -r head base state labelled < <( | ||
| gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" \ | ||
| --jq '[.head.sha, .base.ref, .state, ([.labels[].name] | index("copse-review") != null)] | @tsv' | ||
| ) | ||
| test -n "$head" && test -n "$base" && test "$state" = "open" && test "$labelled" = "true" | ||
| gh workflow run review-ground.yml \ | ||
| --repo "$GITHUB_REPOSITORY" \ | ||
| --ref "$DEFAULT_BRANCH" \ | ||
| -f "pr=${PR_NUMBER}" \ | ||
| -f "head=${head}" \ | ||
| -f "base=${base}" | ||