Skip to content

Commit

Permalink
chore: update sync workflow (#28689)
Browse files Browse the repository at this point in the history
Make the sync workflow a bit more efficient, by only fetching the branches we're actually planning on syncing from `upstream`.

Also document the limitations of GitHub Actions tokens more clearly.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr committed Jan 12, 2024
1 parent e718c90 commit 68d9c8b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/sync-from-upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ jobs:

# Check for the presence of a PROJEN_GITHUB_TOKEN secret.
#
# This is expected to contain a personal access token of someone
# who pas permissions to bypass branch protection rules.
# This is expected to contain a personal access token of someone who has
# permissions to bypass branch protection rules.
#
# If not present, we will use GitHub Actions Token permissions,
# but those are bound by branch protection rules.
# If not present, we can only use GitHub Actions Token permissions,
# but this has the following downsides:
#
# - Those are bound by branch protection rules (so automated pushing won't work).
# - As soon as a workflow file needs to be changed, GitHub will reject the push.
# Only Apps and Users can be allowed to modify workflows.
check-secret:
# Don't run on the target repo itself, only forks
if: github.repository != 'aws/aws-cdk'
Expand Down Expand Up @@ -52,7 +56,7 @@ jobs:
- name: Sync from aws/aws-cdk
run: |-
git remote add upstream https://github.com/aws/aws-cdk.git
git fetch upstream
git fetch upstream $BRANCHES
for branch in $BRANCHES; do
git push origin --force refs/remotes/upstream/$branch:refs/heads/$branch
Expand Down

0 comments on commit 68d9c8b

Please sign in to comment.