更新每日追踪器同步工作流,升级 Node.js 版本并优化提交逻辑
This commit is contained in:
46
.github/workflows/daily-tracker-sync.yml
vendored
46
.github/workflows/daily-tracker-sync.yml
vendored
@@ -2,29 +2,53 @@ name: Daily Tracker Sync
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * *' # 每天凌晨运行
|
- cron: '0 0 * * *' # Daily at 00:00 UTC
|
||||||
workflow_dispatch: # 允许手动在页面点击“重新运行”
|
workflow_dispatch:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-list:
|
update-list:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
|
||||||
image: node:18-bullseye
|
|
||||||
options: --user node
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
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
|
- name: Run sync script
|
||||||
run: node sync-trackers.js
|
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: |
|
run: |
|
||||||
git config --local user.email "action@gitea.com"
|
git config --local user.email "action@github.com"
|
||||||
git config --local user.name "Gitea Action"
|
git config --local user.name "GitHub Action"
|
||||||
git add list/
|
git add list/
|
||||||
git diff --quiet || (
|
git diff --cached --quiet || (
|
||||||
git commit -m "Update tracker list: $(date +%Y-%m-%d)" &&
|
git commit -m "Update tracker list: $(date -u +%F)"
|
||||||
git push origin main
|
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 }}
|
||||||
|
|||||||
Reference in New Issue
Block a user