| 1 |
--- |
| 2 |
name: Approve GitHub Workflows |
| 3 |
permissions: read-all |
| 4 |
|
| 5 |
on: |
| 6 |
pull_request_target: |
| 7 |
types: |
| 8 |
- labeled |
| 9 |
- synchronize |
| 10 |
|
| 11 |
jobs: |
| 12 |
approve: |
| 13 |
name: Approve ok-to-test |
| 14 |
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test') |
| 15 |
runs-on: ubuntu-latest |
| 16 |
permissions: |
| 17 |
actions: write |
| 18 |
steps: |
| 19 |
- name: Update PR |
| 20 |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 21 |
continue-on-error: true |
| 22 |
with: |
| 23 |
github-token: ${{ secrets.GITHUB_TOKEN }} |
| 24 |
debug: ${{ secrets.ACTIONS_RUNNER_DEBUG == 'true' }} |
| 25 |
script: | |
| 26 |
const result = await github.rest.actions.listWorkflowRunsForRepo({ |
| 27 |
owner: context.repo.owner, |
| 28 |
repo: context.repo.repo, |
| 29 |
event: "pull_request", |
| 30 |
status: "action_required", |
| 31 |
head_sha: context.payload.pull_request.head.sha, |
| 32 |
per_page: 100 |
| 33 |
}); |
| 34 |
|
| 35 |
for (var run of result.data.workflow_runs) { |
| 36 |
await github.rest.actions.approveWorkflowRun({ |
| 37 |
owner: context.repo.owner, |
| 38 |
repo: context.repo.repo, |
| 39 |
run_id: run.id |
| 40 |
}); |
| 41 |
} |