From 04438bbd56f2d40c5dc1bfbcf8f4b96361eff9b6 Mon Sep 17 00:00:00 2001 From: Hsdi Date: Mon, 16 Mar 2026 03:18:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=AF=8F=E6=97=A5=E8=BF=BD?= =?UTF-8?q?=E8=B8=AA=E5=99=A8=E5=90=8C=E6=AD=A5=E5=B7=A5=E4=BD=9C=E6=B5=81?= =?UTF-8?q?=EF=BC=8C=E5=8D=87=E7=BA=A7=20Node.js=20=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E6=8F=90=E4=BA=A4=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/daily-tracker-sync.yml | 46 ++++++++++++++++++------ 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/.github/workflows/daily-tracker-sync.yml b/.github/workflows/daily-tracker-sync.yml index 620bc95..af36977 100644 --- a/.github/workflows/daily-tracker-sync.yml +++ b/.github/workflows/daily-tracker-sync.yml @@ -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 }}