Skip to content

Commit cd859be

Browse files
committed
github: add workflow to auto-approve golangci-lint if ok-to-test label is set
1 parent 4b44799 commit cd859be

File tree

1 file changed

+38
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)