Sync #103
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 | |
on: | |
schedule: | |
- cron: '0 0 * * *' # 每天执行一次 | |
workflow_dispatch: # 允许手动触发 | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout your repo | |
uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.PAT_TOKEN }} # 使用个人访问令牌代替默认令牌 | |
- name: Download gfwlist.txt from upstream | |
run: | | |
# 下载文件 | |
curl -L -o gfwlist.txt https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt | |
# 配置 git 提交信息 | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
# 同步分支 | |
git fetch origin main | |
git checkout main | |
git pull origin main # 确保本地分支与远程分支一致 | |
# 添加文件并提交更改(如果有) | |
git add gfwlist.txt | |
if git diff --cached --quiet; then | |
echo "No changes to commit" | |
else | |
git commit -m "Auto-sync gfwlist.txt from upstream" | |
git push origin main | |
fi |