Skip to content

Commit 9872e73

Browse files
committed
add collab-check and wait-for-approval to PR Check workflow
1 parent 48234ae commit 9872e73

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

.github/workflows/codebuild-ci.yml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,39 @@ permissions:
1010
id-token: write # This is required for requesting the JWT
1111

1212
jobs:
13-
codestyle-doc-tests:
13+
collab-check:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
approval-env: ${{ steps.collab-check.outputs.result }}
17+
steps:
18+
- name: Collaborator Check
19+
uses: actions/github-script@v7
20+
id: collab-check
21+
with:
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:
1437
runs-on: ubuntu-latest
38+
needs: [collab-check]
39+
environment: ${{ needs.collab-check.outputs.approval-env }}
1540
steps:
41+
- run: echo "Workflow Approved! Starting PR Checks."
42+
codestyle-doc-tests:
43+
runs-on: ubuntu-latest
44+
needs: [wait-for-approval]
45+
steps:
1646
- name: Configure AWS Credentials
1747
uses: aws-actions/configure-aws-credentials@v4
1848
with:
@@ -23,9 +53,10 @@ jobs:
2353
uses: aws-actions/aws-codebuild-run-build@v1
2454
with:
2555
project-name: sagemaker-python-sdk-ci-codestyle-doc-tests
26-
source-version-override: 'pr/${{ github.event.pull_request.number }}'
56+
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'
2757
unit-tests:
2858
runs-on: ubuntu-latest
59+
needs: [wait-for-approval]
2960
strategy:
3061
fail-fast: false
3162
matrix:
@@ -41,7 +72,7 @@ jobs:
4172
uses: aws-actions/aws-codebuild-run-build@v1
4273
with:
4374
project-name: sagemaker-python-sdk-ci-unit-tests
44-
source-version-override: 'pr/${{ github.event.pull_request.number }}'
75+
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'
4576
env-vars-for-codebuild: |
4677
PY_VERSION
4778
env:

0 commit comments

Comments
 (0)