1
1
name : PR Checks
2
2
on :
3
3
pull_request_target :
4
+ branches :
5
+ - " master*"
4
6
5
7
concurrency :
6
8
group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref }}
@@ -10,9 +12,39 @@ permissions:
10
12
id-token : write # This is required for requesting the JWT
11
13
12
14
jobs :
13
- codestyle-doc-tests :
15
+ collab-check :
16
+ runs-on : ubuntu-latest
17
+ outputs :
18
+ approval-env : ${{ steps.collab-check.outputs.result }}
19
+ steps :
20
+ - name : Collaborator Check
21
+ uses : actions/github-script@v7
22
+ id : collab-check
23
+ with :
24
+ result-encoding : string
25
+ script : |
26
+ try {
27
+ const res = await github.rest.repos.checkCollaborator({
28
+ owner: context.repo.owner,
29
+ repo: context.repo.repo,
30
+ username: "${{ github.event.pull_request.user.login }}",
31
+ });
32
+ console.log("Verifed ${{ github.event.pull_request.user.login }} is a repo collaborator. Auto Approving PR Checks.")
33
+ return res.status == "204" ? "auto-approve" : "manual-approval"
34
+ } catch (error) {
35
+ console.log("${{ github.event.pull_request.user.login }} is not a collaborator. Requiring Manual Approval to run PR Checks.")
36
+ return "manual-approval"
37
+ }
38
+ wait-for-approval :
14
39
runs-on : ubuntu-latest
40
+ needs : [collab-check]
41
+ environment : ${{ needs.collab-check.outputs.approval-env }}
15
42
steps :
43
+ - run : echo "Workflow Approved! Starting PR Checks."
44
+ codestyle-doc-tests :
45
+ runs-on : ubuntu-latest
46
+ needs : [wait-for-approval]
47
+ steps :
16
48
- name : Configure AWS Credentials
17
49
uses : aws-actions/configure-aws-credentials@v4
18
50
with :
23
55
uses : aws-actions/aws-codebuild-run-build@v1
24
56
with :
25
57
project-name : sagemaker-python-sdk-ci-codestyle-doc-tests
26
- source-version-override : ' pr/ ${{ github.event.pull_request.number }}'
58
+ source-version-override : ' refs/pull/ ${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha } }}'
27
59
unit-tests :
28
60
runs-on : ubuntu-latest
61
+ needs : [wait-for-approval]
29
62
strategy :
30
63
fail-fast : false
31
64
matrix :
41
74
uses : aws-actions/aws-codebuild-run-build@v1
42
75
with :
43
76
project-name : sagemaker-python-sdk-ci-unit-tests
44
- source-version-override : ' pr/ ${{ github.event.pull_request.number }}'
77
+ source-version-override : ' refs/pull/ ${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha } }}'
45
78
env-vars-for-codebuild : |
46
79
PY_VERSION
47
80
env :
0 commit comments