Skip to content

Commit ae94767

Browse files
committed
Add github workflow for pull request
Signed-off-by: smoshiur1237 <[email protected]>
1 parent 554e9b5 commit ae94767

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@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.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)