From 471c4d1c8c1e6eb00485de8c0c3f9f172f0b0675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E5=B7=9D=E7=99=BD=E6=B5=AA?= <1679659@qq.com> Date: Sat, 5 Dec 2026 00:28:58 -0700 Subject: [PATCH] ci: reduce publish schedule to daily and skip no-op dist force-push --- .github/workflows/publish.yml | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2e57d8c..766efa1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,7 +8,7 @@ on: - 'withdrawn.json' - 'scripts/**' schedule: - - cron: '0 */2 * * *' + - cron: '17 4 * * *' workflow_dispatch: permissions: @@ -21,6 +21,7 @@ concurrency: jobs: publish: runs-on: ubuntu-latest + timeout-minutes: 15 steps: - name: Checkout plugins repo uses: actions/checkout@v4 @@ -80,7 +81,33 @@ jobs: fi node scripts/build-index.mjs $extra --out-dir dist + - name: Check if dist content changed + id: diff + run: | + if git fetch --depth 1 origin dist 2>/dev/null; then + mkdir -p prev-dist + git show origin/dist:index.json > prev-dist/index.json 2>/dev/null || true + git show origin/dist:changes.json > prev-dist/changes.json 2>/dev/null || true + changed=$(node -e " + const fs = require('fs'); + const norm = (p) => { + if (!fs.existsSync(p)) return ''; + const obj = JSON.parse(fs.readFileSync(p, 'utf8')); + delete obj.updated_at; + return JSON.stringify(obj); + }; + const same = norm('prev-dist/index.json') === norm('dist/index.json') + && norm('prev-dist/changes.json') === norm('dist/changes.json'); + console.log(same ? 'false' : 'true'); + ") + else + changed="true" + fi + echo "changed=$changed" >> "$GITHUB_OUTPUT" + echo "Dist content changed: $changed" + - name: Publish dist orphan branch + if: steps.diff.outputs.changed == 'true' run: | cd dist git init -b dist @@ -94,6 +121,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Purge jsDelivr CDN cache + if: steps.diff.outputs.changed == 'true' run: | curl -fsS "https://purge.jsdelivr.net/gh/${GITHUB_REPOSITORY}@dist/index.json" || true curl -fsS "https://purge.jsdelivr.net/gh/${GITHUB_REPOSITORY}@dist/changes.json" || true