Sync Upstream #1
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 Upstream | |
on: | |
schedule: | |
- cron: '0 */4 * * *' # 每4小时运行一次 | |
workflow_dispatch: # 允许手动触发 | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email 'actions@github.com' | |
- name: Add upstream repository | |
run: | | |
git remote add upstream ${{ vars.UPSTREAM_REPO }} | |
- name: Fetch upstream | |
run: | | |
git fetch upstream | |
- name: Merge upstream | |
run: | | |
git merge upstream/$(git branch --show-current) --no-edit | |
- name: Remove .tool-versions file | |
run: | | |
if [ -f ".tool-versions" ]; then | |
rm .tool-versions | |
git add .tool-versions | |
git commit -m "chore: remove .tool-versions file" | |
fi | |
- name: Push changes | |
run: | | |
git push origin $(git branch --show-current) |