Skip to content

Sync Fork

Sync Fork #965

Workflow file for this run

name: Sync Fork
permissions: {}
on:
schedule:
- cron: '0 */4 * * *' # every 4 hours
workflow_dispatch: # Allow manual triggering
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Set up Git
env:
UPSTREAM_REPO_ACCESS_TOKEN: ${{ secrets.FORK_PAT }}
UPSTREAM_SYNC_REPO: 'nautilus-wraith/.github'
CURRENT_REPO_AND_ORG: ${{ github.repository }}
CURRENT_REPO: ${{ github.event.repository.name }}
USERNAME: ${{ vars.USERNAME }}
EMAIL: ${{ vars.EMAIL }}
run: |
set -e
git clone https://$UPSTREAM_REPO_ACCESS_TOKEN@github.com/$CURRENT_REPO_AND_ORG.git
cd $CURRENT_REPO
git remote set-url origin https://$UPSTREAM_REPO_ACCESS_TOKEN@github.com/$CURRENT_REPO_AND_ORG.git
git config user.name "$USERNAME"
git config user.email "$EMAIL"
git remote add upstream https://$UPSTREAM_REPO_ACCESS_TOKEN@github.com/$UPSTREAM_SYNC_REPO.git
git fetch upstream
# List all branches from upstream and push them to origin
for branch in $(git branch -r | grep 'upstream/' | grep -v 'HEAD' | sed 's/upstream\///'); do
git checkout -B "$branch" "upstream/$branch"
git push origin "$branch" --force
done