diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml new file mode 100644 index 0000000..956a6a2 --- /dev/null +++ b/.github/workflows/cron.yml @@ -0,0 +1,37 @@ +name: cron + +on: + workflow_dispatch: + schedule: + # Cron job every Monday at 12:00 + # https://crontab.guru/every-monday + - cron: '0 0 * * MON' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + token: ${{ secrets.GH_TOKEN }} + - name: Setup Node.js + uses: actions/setup-node@v7 + with: + node-version: lts/* + - name: Setup PNPM + uses: pnpm/action-setup@v6 + with: + version: latest + - name: Install + run: pnpm install --dangerously-allow-all-builds + - name: Cron + run: | + git config --global user.email ${{ secrets.GIT_EMAIL }} + git config --global user.name ${{ secrets.GIT_USERNAME }} + node scripts/postinstall.js --strict + npm test + git add src/headers-order.json + git diff-index --quiet HEAD || git commit -m 'build(update): headers order' --no-verify + git push origin HEAD + curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/8ddbde82-63f2-420c-8e48-373c0800df74 diff --git a/scripts/postinstall.js b/scripts/postinstall.js index 4ec3ad3..ea79d1f 100644 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -5,6 +5,8 @@ const { writeFile } = require('fs/promises') const URL = 'https://raw.githack.com/apify/fingerprint-suite/master/packages/header-generator/src/data_files/headers-order.json' +const isStrict = process.argv.includes('--strict') + fetch(URL) .then(res => { if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`) @@ -13,4 +15,12 @@ fetch(URL) .then(headersOrder => writeFile('src/headers-order.json', JSON.stringify(headersOrder, null, 2)) ) - .catch(error => console.error(error) || process.exit(1)) + .catch(error => { + if (isStrict) { + console.error(error) + process.exit(1) + } + console.warn( + `https-tls: couldn't update headers order, using the bundled one (${error.message})` + ) + })