更新每日追踪器同步工作流,升级 Node.js 版本并优化提交逻辑
All checks were successful
Daily Tracker Sync / update-list (release) Successful in 1m59s
Daily Tracker Sync / update-list (push) Successful in 26s

This commit is contained in:
2026-03-16 03:18:36 +08:00
Unverified
parent 21fedb8572
commit 04438bbd56

View File

@@ -2,29 +2,53 @@ name: Daily Tracker Sync
on:
schedule:
- cron: '0 0 * * *' # 每天凌晨运行
workflow_dispatch: # 允许手动在页面点击“重新运行”
- cron: '0 0 * * *' # Daily at 00:00 UTC
workflow_dispatch:
release:
types:
- published
permissions:
contents: write
jobs:
update-list:
runs-on: ubuntu-latest
container:
image: node:18-bullseye
options: --user node
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Resolve output file
id: output
shell: bash
run: echo "file=list/$(date -u +%F).txt" >> "$GITHUB_OUTPUT"
- name: Run sync script
run: node sync-trackers.js
- name: Commit and Push
- name: Commit and push list changes
if: github.event_name != 'release' && github.ref == 'refs/heads/main'
shell: bash
run: |
git config --local user.email "action@gitea.com"
git config --local user.name "Gitea Action"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add list/
git diff --quiet || (
git commit -m "Update tracker list: $(date +%Y-%m-%d)" &&
git push origin main
git diff --cached --quiet || (
git commit -m "Update tracker list: $(date -u +%F)"
git push origin HEAD:main
)
- name: Upload file to release assets
if: github.event_name == 'release'
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.output.outputs.file }}
overwrite_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}