From f782c766d3cd1b4391f50c9a34ccd862dc901a21 Mon Sep 17 00:00:00 2001 From: TheFakeElon <59686430+TheFakeElon@users.noreply.github.com> Date: Wed, 19 Nov 2025 04:38:46 +1100 Subject: [PATCH 1/6] chore: upstream synchronization action for forks --- .github/workflows/sync-upstream.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/sync-upstream.yml diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml new file mode 100644 index 0000000000..59ca9d4e1e --- /dev/null +++ b/.github/workflows/sync-upstream.yml @@ -0,0 +1,22 @@ +name: Sync Upstream + +on: + schedule: + # Run at 12AM every night, direct workflow dispatch, and on pull request creation + - cron: '0 0 * * *' + workflow_dispatch: { } + pull_request: + types: [opened, reopened, synchronize] +jobs: + sync: + runs-on: ubuntu-latest + permissions: + contents: write + if: ${{ vars.AUTOSYNC_UPSTREAM == 'true' }} + steps: + - name: Sync branch with upstream + run: gh repo sync $REPOSITORY -b $BRANCH_NAME + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPOSITORY: ${{ github.repository }} + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} From 23e60139cbb18ea49cb3211e58c18580863f94e0 Mon Sep 17 00:00:00 2001 From: TheFakeElon <59686430+TheFakeElon@users.noreply.github.com> Date: Sun, 30 Nov 2025 14:57:21 +1100 Subject: [PATCH 2/6] feat: listens to push event and writes to output --- .github/workflows/sync-upstream.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 59ca9d4e1e..f9b458cc78 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -4,18 +4,22 @@ on: schedule: # Run at 12AM every night, direct workflow dispatch, and on pull request creation - cron: '0 0 * * *' - workflow_dispatch: { } + workflow_dispatch: + push: pull_request: - types: [opened, reopened, synchronize] + types: [opened, reopened] jobs: sync: + if: ${{ vars.AUTOSYNC_UPSTREAM == 'true' }} runs-on: ubuntu-latest permissions: contents: write - if: ${{ vars.AUTOSYNC_UPSTREAM == 'true' }} + outputs: + sync_message: ${{ steps.ghsync.outputs.ghsync-out }} steps: - name: Sync branch with upstream - run: gh repo sync $REPOSITORY -b $BRANCH_NAME + id: ghsync + run: echo "ghsync-out=$(gh repo sync $REPOSITORY -b $BRANCH_NAME)" >> $GITHUB_OUTPUT env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPOSITORY: ${{ github.repository }} From bf383132ba2edb836c5a7cd7a2c6d60442bb8e7b Mon Sep 17 00:00:00 2001 From: TheFakeElon <59686430+TheFakeElon@users.noreply.github.com> Date: Sun, 30 Nov 2025 15:02:05 +1100 Subject: [PATCH 3/6] fix: bad syntax --- .github/workflows/sync-upstream.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index f9b458cc78..2b8860c85c 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -15,11 +15,11 @@ jobs: permissions: contents: write outputs: - sync_message: ${{ steps.ghsync.outputs.ghsync-out }} + sync_message: ${{ steps.ghsync.outputs.ghsync_out }} steps: - name: Sync branch with upstream id: ghsync - run: echo "ghsync-out=$(gh repo sync $REPOSITORY -b $BRANCH_NAME)" >> $GITHUB_OUTPUT + run: echo "ghsync_out=$(gh repo sync $REPOSITORY -b $BRANCH_NAME)" >> $GITHUB_OUTPUT env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPOSITORY: ${{ github.repository }} From 95a250e1027d1bf6c68c1085f30ede42fd10f652 Mon Sep 17 00:00:00 2001 From: TheFakeElon <59686430+TheFakeElon@users.noreply.github.com> Date: Sun, 30 Nov 2025 15:03:42 +1100 Subject: [PATCH 4/6] fix: indentation --- .github/workflows/sync-upstream.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 2b8860c85c..c52773f9ea 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -15,10 +15,10 @@ jobs: permissions: contents: write outputs: - sync_message: ${{ steps.ghsync.outputs.ghsync_out }} + sync_message: ${{ steps.ghsync.outputs.ghsync_out }} steps: - name: Sync branch with upstream - id: ghsync + id: ghsync run: echo "ghsync_out=$(gh repo sync $REPOSITORY -b $BRANCH_NAME)" >> $GITHUB_OUTPUT env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d087065ee3bc3716d8ba2c156a427cf15f55a77d Mon Sep 17 00:00:00 2001 From: TheFakeElon <59686430+TheFakeElon@users.noreply.github.com> Date: Sun, 30 Nov 2025 15:13:10 +1100 Subject: [PATCH 5/6] fix: wrong git env var --- .github/workflows/sync-upstream.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index c52773f9ea..d1a52f6fca 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -14,12 +14,10 @@ jobs: runs-on: ubuntu-latest permissions: contents: write - outputs: - sync_message: ${{ steps.ghsync.outputs.ghsync_out }} steps: - name: Sync branch with upstream id: ghsync - run: echo "ghsync_out=$(gh repo sync $REPOSITORY -b $BRANCH_NAME)" >> $GITHUB_OUTPUT + run: echo "gh repo sync $REPOSITORY -b $BRANCH_NAME" >> $GITHUB_STEP_SUMMARY env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPOSITORY: ${{ github.repository }} From b0eaa390333bb8d6d64119b8fed6dc6ea9e8e458 Mon Sep 17 00:00:00 2001 From: TheFakeElon <59686430+TheFakeElon@users.noreply.github.com> Date: Sun, 30 Nov 2025 15:15:35 +1100 Subject: [PATCH 6/6] fix: redundant echo --- .github/workflows/sync-upstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index d1a52f6fca..2c14b7092f 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Sync branch with upstream id: ghsync - run: echo "gh repo sync $REPOSITORY -b $BRANCH_NAME" >> $GITHUB_STEP_SUMMARY + run: gh repo sync $REPOSITORY -b $BRANCH_NAME >> $GITHUB_STEP_SUMMARY env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPOSITORY: ${{ github.repository }}