Sync Fork with Upstream #45
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 with Upstream | |
on: | |
schedule: | |
- cron: '0 1 * * *' # 每天中午1点运行 | |
workflow_dispatch: # 手动触发 | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false # 禁用自动GitHub token | |
fetch-depth: 0 # 获取所有历史记录 | |
- name: Setup git | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Add upstream | |
run: git remote add upstream https://github.com/original_owner/original_repo.git | |
- name: Fetch upstream | |
run: git fetch upstream | |
- name: Merge upstream changes | |
run: git merge upstream/main --allow-unrelated-histories | |
- name: Push changes | |
run: | | |
git push origin main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |