Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: auto-sync every fork from upstream #28653

Merged
merged 4 commits into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/sync-from-upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Sync repository from upstream
on:
workflow_dispatch: {}
schedule:
- cron: 5 2 * * *

env:
BRANCHES: main v2-release

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.
#
# If not present, we will use GitHub Actions Token permissions,
# but those are bound by branch protection rules.
check-secret:
# Don't run on the target repo itself, only forks
if: github.repository != 'aws/aws-cdk'

runs-on: ubuntu-latest
steps:
- name: Check for presence of PROJEN_GITHUB_TOKEN
id: check-secrets
run: |
if [ ! -z "${{ secrets.PROJEN_GITHUB_TOKEN }}" ]; then
echo "ok=true" >> $GITHUB_OUTPUT
else
echo "ok=false" >> $GITHUB_OUTPUT
fi
outputs:
ok: ${{ steps.check-secrets.outputs.ok }}

sync-branch:
runs-on: ubuntu-latest
permissions:
contents: write
needs: [check-secret]
steps:
- name: Checkout using User Token
if: needs.check-secret.outputs.ok == 'true'
uses: actions/checkout@v4
with:
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}

- name: Checkout using GitHub Actions permissions
if: needs.check-secret.outputs.ok == 'false'
uses: actions/checkout@v4

- name: Sync from aws/aws-cdk
run: |-
git remote add upstream https://github.com/aws/aws-cdk.git
git fetch upstream
for branch in $BRANCHES; do
git push origin --force refs/remotes/upstream/$branch:refs/heads/$branch
done
Loading