Skip to content

Instantly share code, notes, and snippets.

@indygwyn
Forked from DewaldDeJager/README.md
Created September 6, 2023 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indygwyn/dcd0f92311d8dda1965666b4281cda36 to your computer and use it in GitHub Desktop.
Save indygwyn/dcd0f92311d8dda1965666b4281cda36 to your computer and use it in GitHub Desktop.
Easy GitHub workflow for keeping a fork in sync with upstream

Sync Fork

This workflow uses the GitHub CLI to keep a forked repo in sync with the upstream repo. Add it to your repo as .github/workflows/sync-fork.yaml.

It runs daily to sync the default branch and can be triggered manually for any branch.

name: sync-fork
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch: { }
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- run: gh repo sync $REPOSITORY -b $BRANCH_NAME
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
BRANCH_NAME: ${{ github.ref_name }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment