Sync Fork #942
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |