Skip to content

Commit 0a5a63f

Browse files
Merge pull request #547 from Nordix/tuomo/add-auto-approver
add workflow to auto-reapprove workflows
2 parents 2147eb0 + f93cf64 commit 0a5a63f

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+
# adapted from github.com/kubernetes-sigs/cluster-api/.github/workflows/pr-gh-workflow-approve.yaml
2+
# this workflow approves workflows if the PR has /ok-to-test
3+
# related Prow feature request https://github.com/kubernetes/test-infra/issues/25210
4+
5+
name: Approve GH Workflows
6+
7+
on:
8+
pull_request_target:
9+
types: [opened, edited, reopened, synchronize, ready_for_review]
10+
11+
permissions: {}
12+
13+
jobs:
14+
approve:
15+
name: Approve on ok-to-test
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
actions: write
20+
21+
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test')
22+
steps:
23+
- name: Update PR
24+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
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)