Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/adoption-monthly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Adoption refresh

# Pulls HTTP Archive custom-metric adoption numbers for spec topics
# (scripts/adoption/) and opens (or updates) a single PR refreshing
# src/data/adoption.json, which the spec pages render automatically.
#
# Runs monthly on the 18th: the crawl for month M lands in BigQuery around
# mid-month M+1, so the 18th reliably picks up the newest available crawl.
# The fetch script itself also falls back to the newest non-empty partition it can find.
#
# One-time setup is documented in scripts/adoption/README.md (GCP project +
# Workload Identity Federation; no long-lived secrets).

on:
schedule:
- cron: "0 6 18 * *" # 18th of each month, 06:00 UTC
workflow_dispatch:

permissions:
contents: write
pull-requests: write
id-token: write

jobs:
refresh:
name: Refresh adoption data
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- uses: google-github-actions/auth@v2
with:
project_id: ${{ vars.GCP_PROJECT_ID }}
workload_identity_provider: ${{ vars.GCP_WIF_PROVIDER }}
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }}

- name: Install dependencies
run: npm ci

- name: Fetch adoption data
run: npm run adoption
env:
GCP_PROJECT_ID: ${{ vars.GCP_PROJECT_ID }}

- name: Format data file
run: npx prettier --write src/data/adoption.json

- name: Detect change
id: diff
run: |
if git diff --quiet -- src/data/adoption.json; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "Adoption data unchanged."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Open or update PR
if: steps.diff.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
branch="chore/refresh-adoption"
crawl=$(node -p "JSON.parse(require('fs').readFileSync('src/data/adoption.json','utf8')).crawl")
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -B "$branch"
git add src/data/adoption.json
git commit -m "chore(adoption): refresh HTTP Archive adoption data ($crawl)"
git push -f -u origin "$branch"
body_file=$(mktemp)
trap 'rm -f "$body_file"' EXIT
printf 'Monthly refresh of the HTTP Archive adoption numbers rendered on the spec pages (`src/data/adoption.json`, crawl `%s`).\n\nGenerated by `npm run adoption` — a single BigQuery aggregation over the newest `httparchive.crawl.pages` crawl partition. Merge to deploy.\n' "$crawl" > "$body_file"
if gh pr view "$branch" --json number >/dev/null 2>&1; then
gh pr edit "$branch" --body-file "$body_file"
else
gh pr create --base main --head "$branch" \
--title "chore(adoption): refresh HTTP Archive adoption data ($crawl)" \
--body-file "$body_file"
fi
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ jobs:
- name: Agent Skill drift check
run: npm run check:skill

- name: Test adoption query
run: npm run test:adoption

- name: Type-check (Astro)
run: npx astro check

Expand Down
Loading
Loading