ci: reduce publish schedule to daily and skip no-op dist force-push

This commit is contained in:
千川白浪 committed 2026-12-05 00:28:58 -07:00
1 parent 108dd9f9c1
commit 471c4d1c8c
1 file changed
+29 -1
+29 -1
View File
@@ -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