Auto-update last updated dates
You can use a GitHub Action to automatically update the last-updated frontmatter property whenever MDX files are modified in a pull request. This keeps your documentation’s “Last updated” timestamp accurate without manual updates.
Set up the workflow
When a pull request is opened or updated, the workflow detects which MDX files changed, updates or adds a last-updated field in their frontmatter with the current date, and commits the changes back to the PR branch. That stamp commit is itself a synchronize event, so the workflow runs a second time on its own commit; the second run stamps the same date, finds no diff, and exits without committing.
Create a token
Give the workflow a personal access token to push its stamp commit with. A push authenticated this way triggers the PR’s other workflows the same way a human push does, so fern check and preview deploys run automatically.
-
Under Settings > Developer settings > Personal access tokens, create a fine-grained token scoped to your docs repository with Contents: Read and write. Classic tokens with the
reposcope also work. -
Add it under Settings > Secrets and variables > Actions as
DOCS_BOT_TOKEN. A token your repository already uses for release or sync automation works too, as does a GitHub App installation token, which avoids per-user expiry on team-maintained repositories.
If your repository runs no other checks on docs PRs, you can skip adding the secret and use the built-in GITHUB_TOKEN instead. GitHub holds every pull_request run the stamp push triggers behind an Approve workflows to run banner until someone with write access approves it, and no repository or organization setting turns this off.
Skip specific pull requests
Stamping every touched page is wrong for a bulk change: a backfill or a sync PR that touches hundreds of pages would rewrite every date to the merge date. Gate the job on a label to opt those PRs out: