ci: reduce publish schedule to daily and skip no-op dist force-push
This commit is contained in:
1 parent
108dd9f9c1
commit
471c4d1c8c
1 file changed
+29
-1
@@ -8,7 +8,7 @@ on:
|
|||||||
- 'withdrawn.json'
|
- 'withdrawn.json'
|
||||||
- 'scripts/**'
|
- 'scripts/**'
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 */2 * * *'
|
- cron: '17 4 * * *'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
@@ -21,6 +21,7 @@ concurrency:
|
|||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout plugins repo
|
- name: Checkout plugins repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -80,7 +81,33 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
node scripts/build-index.mjs $extra --out-dir dist
|
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
|
- name: Publish dist orphan branch
|
||||||
|
if: steps.diff.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
cd dist
|
cd dist
|
||||||
git init -b dist
|
git init -b dist
|
||||||
@@ -94,6 +121,7 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Purge jsDelivr CDN cache
|
- name: Purge jsDelivr CDN cache
|
||||||
|
if: steps.diff.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
curl -fsS "https://purge.jsdelivr.net/gh/${GITHUB_REPOSITORY}@dist/index.json" || true
|
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
|
curl -fsS "https://purge.jsdelivr.net/gh/${GITHUB_REPOSITORY}@dist/changes.json" || true
|
||||||
Reference in new issue
Block a user