Skip to content

Commit b7a6421

Browse files
add-workflow-approval (#345)
Co-authored-by: satish Kumar <satishgollaprolu@gmail.com>
1 parent d0ef46b commit b7a6421

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

.github/workflows/unit_test_coverage.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,37 @@ env:
99
AWS_DEFAULT_REGION: us-west-2
1010

1111
jobs:
12+
collab-check:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
approval-env: ${{ steps.collab-check.outputs.result }}
16+
steps:
17+
- name: Collaborator Check
18+
uses: actions/github-script@v7
19+
id: collab-check
20+
with:
21+
github-token: ${{ github.token }}
22+
result-encoding: string
23+
script: |
24+
try {
25+
const res = await github.rest.repos.checkCollaborator({
26+
owner: context.repo.owner,
27+
repo: context.repo.repo,
28+
username: "${{ github.event.pull_request.user.login }}",
29+
});
30+
console.log("Verifed ${{ github.event.pull_request.user.login }} is a repo collaborator. Auto Approving PR Checks.")
31+
return res.status == "204" ? "auto-approve" : "manual-approval"
32+
} catch (error) {
33+
console.log("${{ github.event.pull_request.user.login }} is not a collaborator. Requiring Manual Approval to run PR Checks.")
34+
return "manual-approval"
35+
}
36+
wait-for-approval:
37+
runs-on: ubuntu-latest
38+
needs: [collab-check]
39+
environment: ${{ needs.collab-check.outputs.approval-env }}
40+
steps:
41+
- run: echo "Workflow Approved! Starting PR Checks."
42+
1243
test_coverage_python:
1344
runs-on: ubuntu-latest
1445
continue-on-error: false

0 commit comments

Comments
 (0)