Skip to content

Commit e882354

Browse files
authored
Merge pull request #2908 from sbueringer/pr-approve-action
🌱 Add action to approve actions if ok-to-test is set
2 parents 6a7af3d + 57dba0e commit e882354

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
permissions: {}
12+
13+
jobs:
14+
approve:
15+
name: Approve ok-to-test
16+
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test')
17+
runs-on: ubuntu-latest
18+
permissions:
19+
actions: write
20+
steps:
21+
- name: Update PR
22+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
23+
continue-on-error: true
24+
with:
25+
github-token: ${{ secrets.GITHUB_TOKEN }}
26+
script: |
27+
const result = await github.rest.actions.listWorkflowRunsForRepo({
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
event: "pull_request",
31+
status: "action_required",
32+
head_sha: context.payload.pull_request.head.sha,
33+
per_page: 100
34+
});
35+
36+
for (var run of result.data.workflow_runs) {
37+
await github.rest.actions.approveWorkflowRun({
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
run_id: run.id
41+
});
42+
}

0 commit comments

Comments
 (0)