Skip to content

feat(ci): sync GitVersion schema to SchemaStore on new schema releases - #5018

Merged
arturcic merged 4 commits into
mainfrom
feature/schemastore-sync
Jul 3, 2026
Merged

feat(ci): sync GitVersion schema to SchemaStore on new schema releases#5018
arturcic merged 4 commits into
mainfrom
feature/schemastore-sync

Conversation

@arturcic

@arturcic arturcic commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

Adds .github/workflows/schemastore.yml, which automates opening a PR against SchemaStore/schemastore whenever a new GitVersion schema version is published, per #5017.

How it works

  • Trigger: pushes to gh-pages that touch schemas/** (i.e. right after docs.yml publishes docs and the generated schema for the release), or workflow_dispatch with a version input for manual re-runs.
  • Detection: on the automatic trigger, diffs before/after on gh-pages for newly added schemas/*/GitVersion.configuration.json files and derives the version from the folder name. If nothing new was added (e.g. a patch release with no new schema), the job no-ops. On manual trigger, the provided version input is used directly instead.
  • Auth: uses a single token from gittools/cicd/github-creds (same mechanism as homebrew.yml uses for opening PRs against homebrew-core) for both pushing to the GitTools/schemastore fork and opening the PR against the upstream repo. A GitHub App token was considered (as used in gittools-actions.yml), but App installation tokens are scoped to repos the app is installed on and can't open a PR against SchemaStore/schemastore, which GitTools doesn't control — so a single PAT-based identity (like homebrew.yml) is the correct fit here.
  • Update logic:
    1. gh repo sync brings the GitTools/schemastore fork's master up to date with upstream.
    2. Clones the fork, branches as gitversion-schema-<version>.
    3. Uses jq to bump the GitVersion entry's url, add the new versions map entry in src/api/json/catalog.json, and update the $ref in src/schemas/json/gitversion.json — matching SchemaStore/schemastore#5485.
    4. Commits, pushes, and opens the PR via gh pr create --repo SchemaStore/schemastore.

Test plan

  • actionlint passes on the new workflow (verified locally).
  • Manually trigger via workflow_dispatch with a real historical version (e.g. 6.7) against a test fork to confirm the jq edits and PR creation work end-to-end, since this can't be exercised from a local sandbox (needs OP_SERVICE_ACCOUNT_TOKEN and push access to GitTools/schemastore).
  • Confirm the automatic trigger correctly detects a newly-added schema folder on the next real release that ships a new schema version.

Copilot AI review requested due to automatic review settings July 3, 2026 06:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new GitHub Actions workflow to automate opening a PR against SchemaStore/schemastore when GitVersion publishes a new JSON schema version, addressing the manual update process described in #5017.

Changes:

  • Adds .github/workflows/schemastore.yml to detect newly-added schema versions and open a SchemaStore PR via gh + jq.
  • Supports both automatic triggering (intended on gh-pages schema updates) and manual reruns via workflow_dispatch with a version input.

Comment thread .github/workflows/schemastore.yml
Comment thread .github/workflows/schemastore.yml
@arturcic arturcic linked an issue Jul 3, 2026 that may be closed by this pull request
3 tasks
arturcic added 2 commits July 3, 2026 08:31
… error in homebrew.yml

- schemastore.yml: pass github context/inputs through env vars instead of
  interpolating them directly into the run block (Sonar S7630).
- homebrew.yml: remove a stray `--fork-org gittools` line missing its line
  continuation, which broke the brew bump-formula-pr command and tripped
  shellcheck SC2215.
gh-pages has no .github/workflows directory, so a push-based trigger on
that branch would never fire — GitHub Actions resolves branch-scoped
event filters using the workflow file as it exists on the pushed ref.
Switch to workflow_run keyed off docs.yml completing, which is
evaluated from the default branch. Detect the new version by diffing
HEAD~1..HEAD on gh-pages instead of the push event's before/after SHAs.
Copilot AI review requested due to automatic review settings July 3, 2026 07:11
@arturcic

arturcic commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Good catches, thanks — both fixed in 91fa2c3:

  • Trigger: switched from push: branches: [gh-pages] to workflow_run keyed off docs.yml ("Verify & Publish Docs") completing. Confirmed gh-pages has no .github/workflows directory at all, so the push trigger would indeed never have fired.
  • Diff: since workflow_run doesn't give a push before/after, the version detection now diffs HEAD~1..HEAD on gh-pages instead (docs.yml pushes a single commit per run), which also sidesteps the fetch-depth/before-SHA-availability issue.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread .github/workflows/schemastore.yml Outdated
Comment thread .github/workflows/schemastore.yml
Revert the workflow_run approach: docs.yml's PublishDocs task now copies
schemastore.yml into the gh-pages commit it publishes, so the branch
actually has the workflow file GitHub needs to resolve a push-triggered
event on gh-pages itself. Also widen checkout to fetch-depth: 0 so the
before/after diff is always valid, regardless of how many commits a
gh-pages push contains.
@arturcic

arturcic commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Update: reverted to a pure push: branches: [gh-pages] + workflow_dispatch trigger (per maintainer request — the workflow_run approach changed what triggers it, which wasn't the intent).

To make the push trigger actually work, docs.yml's PublishDocs task now also copies .github/workflows/schemastore.yml into the gh-pages commit it publishes, so the workflow file exists on that branch (GitHub resolves push-triggered workflows using the file as it exists on the pushed ref). Also widened checkout to fetch-depth: 0 so the before/after diff is always valid regardless of how many commits a gh-pages push contains.

@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

@arturcic
arturcic merged commit 97ae8e5 into main Jul 3, 2026
138 of 140 checks passed
@arturcic
arturcic deleted the feature/schemastore-sync branch July 3, 2026 08:02
@mergify

mergify Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Thank you @arturcic for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automate SchemaStore PR creation for new minor/major releases

2 participants