Skip to content

Commit d55290d

Browse files
authored
Merge branch 'master' into fix-typo
2 parents 9c29a17 + 2488581 commit d55290d

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

.github/workflows/codebuild-ci.yml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: PR Checks
22
on:
33
pull_request_target:
4+
branches:
5+
- "master*"
46

57
concurrency:
68
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref }}
@@ -10,9 +12,39 @@ permissions:
1012
id-token: write # This is required for requesting the JWT
1113

1214
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:
1439
runs-on: ubuntu-latest
40+
needs: [collab-check]
41+
environment: ${{ needs.collab-check.outputs.approval-env }}
1542
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:
1648
- name: Configure AWS Credentials
1749
uses: aws-actions/configure-aws-credentials@v4
1850
with:
@@ -23,9 +55,10 @@ jobs:
2355
uses: aws-actions/aws-codebuild-run-build@v1
2456
with:
2557
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 }}}'
2759
unit-tests:
2860
runs-on: ubuntu-latest
61+
needs: [wait-for-approval]
2962
strategy:
3063
fail-fast: false
3164
matrix:
@@ -41,7 +74,7 @@ jobs:
4174
uses: aws-actions/aws-codebuild-run-build@v1
4275
with:
4376
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 }}}'
4578
env-vars-for-codebuild: |
4679
PY_VERSION
4780
env:

0 commit comments

Comments
 (0)