Skip to content

Notify price alerts #28

Notify price alerts

Notify price alerts #28

Workflow file for this run

name: Notify price alerts
# Fires when published prices actually change on the branch the site deploys
# from — which is the only moment a subscriber would want to hear about.
#
# Human-reviewed merges arrive through the push trigger. Bot-authored commits
# use GITHUB_TOKEN, which GitHub deliberately prevents from triggering another
# workflow; sync-pricing.yml therefore dispatches this workflow explicitly only
# after it has successfully pushed a published catalog to main.
#
# The script exits 0 without sending anything when ALERTS_API or NOTIFY_SECRET
# is unset, so this stays green until the worker has a domain.
on:
push:
branches: [main]
paths:
- 'public/data/pricing.json'
workflow_dispatch:
permissions:
contents: read
concurrency:
# Two pushes in quick succession must not race into two overlapping fan-outs.
# The worker deduplicates by event id as well, but not queueing them at all is
# cheaper than relying on that.
group: notify-alerts
cancel-in-progress: false
jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
# Pushes may contain several commits. The script uses the event's
# before SHA, so the complete reachable history must be available.
fetch-depth: 0
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: 22
cache: npm
- name: Install reviewed dependencies only
run: |
npm ci --ignore-scripts
npm rebuild esbuild
- name: Notify subscribers
env:
ALERTS_API: ${{ vars.ALERTS_API }}
NOTIFY_SECRET: ${{ secrets.NOTIFY_SECRET }}
BEFORE_SHA: ${{ github.event.before }}
run: npx tsx scripts/notify-alerts.ts
# Same trigger, different audience: subscribers hear about the change,
# and so do the search engines whose model pages just went out of date.
#
# `continue-on-error` because this is an optimisation on top of ordinary
# crawling. A refused submission must not turn a perfectly good pricing
# update into a red build — the script already downgrades its own failures
# to warnings, and this is the belt to that pair of braces.
- name: Submit the changed pages to IndexNow
continue-on-error: true
env:
SITE_URL: ${{ vars.SITE_URL }}
run: npx tsx scripts/ping-indexnow.ts