@@ -2,14 +2,7 @@ name: Build SDK
22on :
33 merge_group :
44 pull_request_target :
5- types : [opened, synchronize, reopened, labeled]
6- push :
7- branches :
8- - master
9- paths-ignore :
10- - ' **.md'
11- - ' .all-contributorsrc'
12- - ' docs/**'
5+ types : [opened, synchronize, reopened]
136
147concurrency :
158 group : start-pull-request-build-${{ github.event.pull_request.number || github.ref }}
2013 SCRIPT_LOCATION : ' workflows/start-pull-request-build/pull-request-build-v1.sh'
2114
2215jobs :
23- # Strip the safe-to-build label on every new push from a fork so that
24- # a maintainer must re-review and re-label after each update.
25- revoke-approval :
26- if : >
27- github.event_name == 'pull_request_target' &&
28- github.event.action == 'synchronize' &&
29- github.event.pull_request.head.repo.full_name != github.repository
30- runs-on : ubuntu-latest
31- permissions :
32- pull-requests : write
33- steps :
34- - name : Remove safe-to-build label
35- env :
36- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
37- run : |
38- gh api -X DELETE \
39- "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/safe-to-build" \
40- || true # 404 if label wasn't present
41-
4216 aws-sdk-pr-build :
43- needs : revoke-approval
17+ # Skip draft PRs
4418 if : >
45- always() &&
46- needs.revoke-approval.result != 'failure' &&
47- (
48- github.event_name != 'pull_request_target' ||
49- (
50- github.event.pull_request.draft == false &&
51- (
52- github.event.pull_request.head.repo.full_name == github.repository ||
53- contains(github.event.pull_request.labels.*.name, 'safe-to-build')
54- )
55- )
56- )
19+ github.event_name != 'pull_request_target' ||
20+ github.event.pull_request.draft == false
5721 runs-on : ubuntu-latest
5822 permissions :
5923 id-token : write
6024 issues : write
6125 pull-requests : write
6226 contents : read
27+ # For fork PRs, require manual approval via the "fork-ci" environment.
28+ # Internal PRs and merge_group events run immediately (no environment gate).
29+ # Setup: create a "fork-ci" environment in repo Settings > Environments with
30+ # - Required reviewers: your maintainer team
31+ # - Move PR_WORKFLOW_IAM_ROLE_ARN to the environment's secrets
32+ environment : >-
33+ ${{
34+ github.event_name == 'pull_request_target' &&
35+ github.event.pull_request.head.repo.full_name != github.repository &&
36+ 'fork-ci' || ''
37+ }}
6338 steps :
6439 - name : Configure AWS Credentials
6540 uses : aws-actions/configure-aws-credentials@v4
6641 with :
67- role-to-assume : ${{secrets.PR_WORKFLOW_IAM_ROLE_ARN}}
42+ role-to-assume : ${{ secrets.PR_WORKFLOW_IAM_ROLE_ARN }}
6843 role-session-name : PullRequestBuildGitHubAction
6944 aws-region : us-west-2
7045 role-duration-seconds : 10800 # 3 hrs
@@ -75,11 +50,11 @@ jobs:
7550 - name : Build
7651 env :
7752 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
78- HEAD_REF : ${{ github.event.pull_request.head.ref }}
53+ HEAD_SHA : ${{ github.event.pull_request.head.sha }}
7954 run : |
8055 ./$DOWNLOAD_FOLDER/$SCRIPT_LOCATION \
8156 --repo "${{ github.repository }}" \
82- --branch "$HEAD_REF " \
57+ --branch "$HEAD_SHA " \
8358 --pr-number "${{ github.event.pull_request.number }}" \
8459 --run-id "${{ github.run_id }}"
8560 timeout-minutes : 120
0 commit comments