Skip to content

Commit d5326e4

Browse files
Kikobeatsclaude
andauthored
ci: add weekly cron to refresh headers-order.json (#30)
* ci: add weekly cron to refresh headers-order.json Same shape as country-vat: run the postinstall fetcher, gate on the test suite, commit `build(update): headers order` only when the file changed, push with GH_TOKEN so main.yml releases the new data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(cron): ping healthcheck after update Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(postinstall): warn instead of failing the install A failed fetch (offline install, upstream down) used to exit 1 and break `npm install https-tls`. It now warns and keeps the bundled file. The cron runs it with --strict so a broken fetch still fails the job and skips the healthcheck ping instead of passing silently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c68884c commit d5326e4

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

‎.github/workflows/cron.yml‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: cron
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# Cron job every Monday at 12:00
7+
# https://crontab.guru/every-monday
8+
- cron: '0 0 * * MON'
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v7
16+
with:
17+
token: ${{ secrets.GH_TOKEN }}
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v7
20+
with:
21+
node-version: lts/*
22+
- name: Setup PNPM
23+
uses: pnpm/action-setup@v6
24+
with:
25+
version: latest
26+
- name: Install
27+
run: pnpm install --dangerously-allow-all-builds
28+
- name: Cron
29+
run: |
30+
git config --global user.email ${{ secrets.GIT_EMAIL }}
31+
git config --global user.name ${{ secrets.GIT_USERNAME }}
32+
node scripts/postinstall.js --strict
33+
npm test
34+
git add src/headers-order.json
35+
git diff-index --quiet HEAD || git commit -m 'build(update): headers order' --no-verify
36+
git push origin HEAD
37+
curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/8ddbde82-63f2-420c-8e48-373c0800df74

‎scripts/postinstall.js‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const { writeFile } = require('fs/promises')
55
const URL =
66
'https://raw.githack.com/apify/fingerprint-suite/master/packages/header-generator/src/data_files/headers-order.json'
77

8+
const isStrict = process.argv.includes('--strict')
9+
810
fetch(URL)
911
.then(res => {
1012
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`)
@@ -13,4 +15,12 @@ fetch(URL)
1315
.then(headersOrder =>
1416
writeFile('src/headers-order.json', JSON.stringify(headersOrder, null, 2))
1517
)
16-
.catch(error => console.error(error) || process.exit(1))
18+
.catch(error => {
19+
if (isStrict) {
20+
console.error(error)
21+
process.exit(1)
22+
}
23+
console.warn(
24+
`https-tls: couldn't update headers order, using the bundled one (${error.message})`
25+
)
26+
})

0 commit comments

Comments
 (0)