Skip to content

Switch series resolution to Hashnode GraphQL API #14

Switch series resolution to Hashnode GraphQL API

Switch series resolution to Hashnode GraphQL API #14

Workflow file for this run

name: Build README index
on:
push:
branches: [main]
paths:
- "*.md"
# series.yml is a push trigger so a manual series.yml update (applied
# by hand on the mirror) regenerates README.md via CI. The bot's own
# README commit is pushed with the default GITHUB_TOKEN, which does not
# trigger another workflow run, so this cannot recurse.
- "series.yml"
- "tools/build-index.py"
- "tools/update-series.py"
- ".github/workflows/build-index.yml"
workflow_dispatch:
inputs:
refresh_series:
description: >-
Refresh series.yml from the Hashnode GraphQL API (requires the
HASHNODE_PAT repository secret; see series.yml header).
type: boolean
default: false
permissions:
contents: write
concurrency:
group: build-index
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: pip install pyyaml
# Series resolution reads the Hashnode GraphQL API and needs the
# HASHNODE_PAT repository secret (paid-plan token). Normal pushes only
# regenerate README.md from the committed series.yml; the refresh runs
# on manual dispatch with refresh_series=true. Local runs remain the
# default path (see tools/MAINTAINING.md).
- name: Refresh series mapping from the Hashnode API (manual)
if: github.event_name == 'workflow_dispatch' && inputs.refresh_series
continue-on-error: true
env:
HASHNODE_PAT: ${{ secrets.HASHNODE_PAT }}
run: python tools/update-series.py
- name: Build README
if: always()
run: python tools/build-index.py
- name: Commit if changed
if: always()
run: |
if [[ -n "$(git status --porcelain series.yml README.md)" ]]; then
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add series.yml README.md
git commit -m "chore: refresh series mapping and README index"
git push
else
echo "series.yml and README are up to date."
fi