Sync Fork #71
This file contains 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 | |
on: | |
schedule: | |
- cron: '0 0 * * *' # 每天0点运行一次 | |
workflow_dispatch: # 允许手动触发 | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Check for changes | |
id: check_changes | |
run: | | |
git remote add upstream https://github.com/wzdnzd/aggregator.git | |
git fetch upstream | |
# 检查两个分支之间是否有差异 | |
DIFF_COUNT=$(git rev-list --count upstream/main...main) | |
echo "diff_count=$DIFF_COUNT" >> $GITHUB_ENV | |
if [ "$DIFF_COUNT" -eq "0" ]; then | |
echo "No changes detected between branches" | |
exit 0 | |
fi | |
- name: Debug Info | |
run: | | |
echo "DIFF_COUNT: ${{ env.diff_count }}" | |
git branch -r | |
git remote -v | |
- name: Sync Fork | |
if: ${{ env.diff_count != '0' }} | |
uses: tgymnich/fork-sync@v1.8 | |
with: | |
upstream_repository: wzdnzd/aggregator | |
upstream_branch: main | |
target_branch: main |