Skip to content

Commit 3007652

Browse files
authored
Merge pull request #946 from richardcase/approve_workflows
🌱 chore: approve workflows on ok-to-test
2 parents 324c696 + 8accebe commit 3007652

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: PR approve GH Workflows
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- edited
7+
- labeled
8+
- reopened
9+
- synchronize
10+
11+
jobs:
12+
approve:
13+
name: Approve ok-to-test
14+
15+
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test')
16+
17+
runs-on: ubuntu-latest
18+
19+
permissions:
20+
actions: write
21+
22+
steps:
23+
- name: Update PR
24+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
25+
continue-on-error: true
26+
with:
27+
github-token: ${{ secrets.GITHUB_TOKEN }}
28+
script: |
29+
const result = await github.rest.actions.listWorkflowRunsForRepo({
30+
owner: context.repo.owner,
31+
repo: context.repo.repo,
32+
event: "pull_request",
33+
status: "action_required",
34+
head_sha: context.payload.pull_request.head.sha,
35+
per_page: 100
36+
});
37+
38+
for (var run of result.data.workflow_runs) {
39+
await github.rest.actions.approveWorkflowRun({
40+
owner: context.repo.owner,
41+
repo: context.repo.repo,
42+
run_id: run.id
43+
});
44+
}

0 commit comments

Comments
 (0)