This repository provides a reusable GitHub Actions workflow that keeps a fork’s default branch in sync with its upstream repository on a schedule or manual trigger.
Listener (sync-upstream.yml)
- Runs on a cron schedule or when manually triggered.
- Checks out the fork’s default branch.
- Adds the specified upstream remote.
- Fetches and merges the latest commits from upstream.
- Pushes the updated branch back to the fork.
-
Add the workflow
Placesync-upstream.yml
in your fork under.github/workflows/
. -
Customize the upstream
In theAdd upstream remote
step, update the URL to your upstream repo:git remote add upstream https://github.com/ORIGINAL-OWNER/ORIGINAL-REPO.git
Replace
ORIGINAL-OWNER/ORIGINAL-REPO
with the repository you forked. -
Ensure repository settings
- The repository must be public.
- The workflow runs on your default branch (e.g.,
main
ormaster
).
To allow this workflow to run, your organization’s Actions policy must permit the actions/checkout@v4 action and first-party workflows:
- Go to Organization Settings → Actions → General → Policies.
- Select Allow Le-Fork, and select non-Le-Fork, actions and reusable workflows.
Note: you should change Le-Fork with your organization's name. - Under Allow actions created by GitHub, ensure it is checked.
- Under Allow actions by Marketplace verified creators, ensure it is checked.
- In the “Allow or block specified actions and reusable workflows” textbox, list exactly:
actions/checkout@v4
- Scheduled sync: The workflow’s cron schedule runs daily at 05:00 UTC by default.
- Manual trigger: Go to Actions → Sync from upstream → Run workflow.
Example schedule in sync-upstream.yml
:
on:
schedule:
- cron: '0 5 * * *' # daily at 05:00 UTC
workflow_dispatch: # manual trigger
Your workflow requires permission to push changes:
permissions:
contents: write
In Settings → Actions → General, ensure Read and write permissions is enabled. If it’s greyed out, ask an administrator to grant write access.
- Always keep the upstream URL in the workflow updated if you ever change the fork’s source.
- Each fork only needs this listener workflow; there’s no central dispatcher required unless you want to automate across multiple forks.