Skip to content

Commit 241bda3

Browse files
authored
chore: add remote branch check to workflows (#33525)
### Issue # (if applicable) n/a ### Reason for this change Adhere to best security practices. ### Description of changes Fetch remote branch to check for any unapproved commits to the remote branch and only commit/push if there are not. ### Describe any new or updated permissions being added n/a ### Description of how you validated changes Tested the commands locally ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 1b116b9 commit 241bda3

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.github/workflows/analytics-metadata-updater.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ jobs:
4747
run: |
4848
git config --global user.name 'aws-cdk-automation'
4949
git config --global user.email '[email protected]'
50-
git checkout -B ${{ github.event.pull_request.head.ref }}
50+
51+
git fetch origin ${{ github.event.pull_request.head.ref }}
52+
53+
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/${{ github.event.pull_request.head.ref }})" ]; then
54+
echo "Remote branch updated since approved commit; aborting."
55+
exit 1
56+
fi
57+
5158
git add .
5259
git commit -m "chore: update analytics metadata blueprints"
5360
git push origin ${{ github.event.pull_request.head.ref }}

.github/workflows/lambda-runtime-tests.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ jobs:
4444
run: |
4545
git config --global user.name 'aws-cdk-automation'
4646
git config --global user.email '[email protected]'
47-
git checkout -B ${{ github.event.pull_request.head.ref }}
47+
48+
git fetch origin ${{ github.event.pull_request.head.ref }}
49+
50+
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/${{ github.event.pull_request.head.ref }})" ]; then
51+
echo "Remote branch updated since approved commit; aborting."
52+
exit 1
53+
fi
54+
4855
git add .
4956
git commit -m "chore: update lambda runtime integration tests"
5057
git push origin ${{ github.event.pull_request.head.ref }}

0 commit comments

Comments
 (0)