From f73ba9a9bac23f8bb272ad2799deb97ce6379b95 Mon Sep 17 00:00:00 2001 From: smilkuri Date: Wed, 3 Sep 2025 19:05:22 +0000 Subject: [PATCH 1/3] chore(ci): integrate build workflow for PRs --- .github/workflows/pull-request-build.yml | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/pull-request-build.yml diff --git a/.github/workflows/pull-request-build.yml b/.github/workflows/pull-request-build.yml new file mode 100644 index 00000000000..61d3b107654 --- /dev/null +++ b/.github/workflows/pull-request-build.yml @@ -0,0 +1,45 @@ +name: Build SDK +on: + pull_request_review: + types: [ submitted ] + branches: [ main ] + +concurrency: + group: start-pull-request-build-${{ github.ref }} + cancel-in-progress: true + +env: + IAM_ROLE_ARN: 'arn:aws:iam::088667348242:role/AwsSdkJsV3GitHubRole' + DOWNLOAD_FOLDER: '.build-scripts/' + SCRIPT_LOCATION: 'workflows/start-pull-request-build/pull-request-build-v1.sh' + +jobs: + aws-sdk-pr-build: + if: github.event.review.state == 'approved' + runs-on: ubuntu-latest + permissions: + id-token: write + issues: write + pull-requests: write + contents: read + steps: + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ env.IAM_ROLE_ARN }} + role-session-name: PullRequestBuildGitHubAction + aws-region: us-west-2 + - name: Download Build Script + run: | + aws s3 cp s3://aws-sdk-builds-github-assets-prod-us-west-2/$SCRIPT_LOCATION ./$DOWNLOAD_FOLDER/$SCRIPT_LOCATION --no-progress + chmod +x ./$DOWNLOAD_FOLDER/$SCRIPT_LOCATION + - name: Build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + ./$DOWNLOAD_FOLDER/$SCRIPT_LOCATION \ + --repo "${{ github.repository }}" \ + --branch "${{ github.event.pull_request.head.ref }}" \ + --pr-number "${{ github.event.pull_request.number }}" \ + --run-id "${{ github.run_id }}" + timeout-minutes: 510 # 8.5 hours \ No newline at end of file From 78917332865a7bd5e0b618a86542a2e14c0e1b21 Mon Sep 17 00:00:00 2001 From: smilkuri Date: Thu, 4 Sep 2025 11:41:24 +0000 Subject: [PATCH 2/3] chore(ci): increase token expiration to 2 hrs --- .github/workflows/pull-request-build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request-build.yml b/.github/workflows/pull-request-build.yml index 61d3b107654..e74f7833594 100644 --- a/.github/workflows/pull-request-build.yml +++ b/.github/workflows/pull-request-build.yml @@ -29,6 +29,7 @@ jobs: role-to-assume: ${{ env.IAM_ROLE_ARN }} role-session-name: PullRequestBuildGitHubAction aws-region: us-west-2 + role-duration-seconds: 7200 - name: Download Build Script run: | aws s3 cp s3://aws-sdk-builds-github-assets-prod-us-west-2/$SCRIPT_LOCATION ./$DOWNLOAD_FOLDER/$SCRIPT_LOCATION --no-progress @@ -42,4 +43,4 @@ jobs: --branch "${{ github.event.pull_request.head.ref }}" \ --pr-number "${{ github.event.pull_request.number }}" \ --run-id "${{ github.run_id }}" - timeout-minutes: 510 # 8.5 hours \ No newline at end of file + timeout-minutes: 120 # 2 hours \ No newline at end of file From e91c8af1a3b89f27f1a32987449e47a26eddba1e Mon Sep 17 00:00:00 2001 From: Sreeja Milkuri Date: Fri, 5 Sep 2025 10:16:44 -0400 Subject: [PATCH 3/3] prevent code injection in GitHub workflow actions --- .github/workflows/pull-request-build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request-build.yml b/.github/workflows/pull-request-build.yml index e74f7833594..1888f614d62 100644 --- a/.github/workflows/pull-request-build.yml +++ b/.github/workflows/pull-request-build.yml @@ -37,10 +37,11 @@ jobs: - name: Build env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HEAD_REF: ${{ github.event.pull_request.head.ref }} run: | ./$DOWNLOAD_FOLDER/$SCRIPT_LOCATION \ --repo "${{ github.repository }}" \ - --branch "${{ github.event.pull_request.head.ref }}" \ + --branch "$HEAD_REF" \ --pr-number "${{ github.event.pull_request.number }}" \ --run-id "${{ github.run_id }}" - timeout-minutes: 120 # 2 hours \ No newline at end of file + timeout-minutes: 120 # 2 hours