chore: trigger sync name (testing) #6
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 Repository | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| repository_dispatch: | |
| types: [upstream-update] | |
| workflow_dispatch: | |
| env: | |
| FORK_REPO: "git-good-w/git-animal-client" | |
| UPSTREAM_REPO: "git-goods/git-animal-client" | |
| jobs: | |
| trigger-sync: | |
| if: vars.IS_FORK_REPO == '' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Trigger fork repository sync | |
| run: | | |
| echo "π Triggering sync for fork: ${{ env.FORK_REPO }}" | |
| echo "π Branch pushed: ${{ github.ref_name }}" | |
| curl -X POST \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| -H "Authorization: token ${{ secrets.FORK_SYNC_TOKEN }}" \ | |
| https://api.github.com/repos/${{ env.FORK_REPO }}/dispatches \ | |
| -d '{"event_type":"upstream-update","client_payload":{"branch":"${{ github.ref_name }}","commit":"${{ github.sha }}"}}' | |
| echo "β Fork sync triggered" | |
| sync-upstream: | |
| if: vars.IS_FORK_REPO != '' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| actions: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Sync with upstream | |
| run: | | |
| echo "π Syncing from upstream: ${{ env.UPSTREAM_REPO }}" | |
| git remote add upstream https://github.com/${{ env.UPSTREAM_REPO }}.git | |
| git fetch upstream | |
| # main λΈλμΉ λκΈ°ν | |
| echo "π¦ Syncing main branch..." | |
| git checkout -B main origin/main | |
| git merge upstream/main --no-edit | |
| git push origin main | |
| echo "β main branch synced" | |
| # dev λΈλμΉ λκΈ°ν | |
| echo "π¦ Syncing dev branch..." | |
| git checkout -B dev origin/dev 2>/dev/null || git checkout -b dev upstream/dev | |
| git merge upstream/dev --no-edit | |
| git push origin dev | |
| echo "β dev branch synced" | |
| - name: Summary | |
| run: | | |
| echo "β¨ Sync completed successfully!" | |
| echo "Upstream: ${{ env.UPSTREAM_REPO }}" |