diff --git a/.github/workflows/upstream-sync.yml b/.github/workflows/upstream-sync.yml new file mode 100644 index 000000000..84acc04c0 --- /dev/null +++ b/.github/workflows/upstream-sync.yml @@ -0,0 +1,45 @@ +name: Sync Upstream Branches + +on: + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +jobs: + sync: + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Add upstream remote + run: | + git remote add upstream https://github.com/xixu-me/Xget.git + + - name: Fetch all upstream branches + run: | + git fetch upstream + + - name: Sync all upstream branches + run: | + for branch in $(git branch -r | grep 'upstream/' | grep -v 'HEAD' | sed 's|upstream/||'); do + echo "Syncing branch: $branch" + git checkout -B "$branch" "upstream/$branch" + git push origin "$branch" --force + done