From fd8e3000533e78551d7bba611bde19555503f113 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Sat, 27 Jun 2026 15:16:08 -1000 Subject: [PATCH] ci: add bot to sync prompt artifacts from upstream prompts.yml --- .github/workflows/sync-upstream-prompts.yml | 79 +++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/sync-upstream-prompts.yml diff --git a/.github/workflows/sync-upstream-prompts.yml b/.github/workflows/sync-upstream-prompts.yml new file mode 100644 index 0000000..0e5dfcb --- /dev/null +++ b/.github/workflows/sync-upstream-prompts.yml @@ -0,0 +1,79 @@ +name: Sync upstream prompt artifacts + +# The committed prompt artifacts (prototypes/docusaurus/src/constants/prompts.ts, +# prototypes/docusaurus/static/prompts.json, prototypes/docusaurus/static/prompts/llms.txt) +# are generated from react_on_rails `prompts.yml`. The site build regenerates +# them and fails on drift (scripts/prepare-prompts.mjs), so when upstream +# `prompts.yml` changes they go stale and every PR turns red. This job +# regenerates them from react_on_rails main and opens a PR, mirroring +# react_on_rails' own `update-llms-full.yml` bot. + +on: + schedule: + - cron: '40 4 * * *' + workflow_dispatch: + repository_dispatch: + types: [docs-updated] + +permissions: + contents: write + pull-requests: write + +concurrency: + group: sync-upstream-prompts + cancel-in-progress: false + +jobs: + sync-prompts: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + persist-credentials: false + + - name: Setup Node + uses: actions/setup-node@v5 + with: + node-version: 24 + + - name: Regenerate docs + prompt artifacts from react_on_rails main + run: npm run prepare + env: + REACT_ON_RAILS_REPO_URL: https://github.com/shakacode/react_on_rails.git + REACT_ON_RAILS_REF: main + + - name: Detect prompt-artifact changes + id: changes + run: | + set -euo pipefail + paths="prototypes/docusaurus/src/constants/prompts.ts prototypes/docusaurus/static/prompts.json prototypes/docusaurus/static/prompts/llms.txt" + if git diff --quiet -- $paths; then + echo "changed=false" >> "$GITHUB_OUTPUT" + echo "Prompt artifacts already current." + else + echo "changed=true" >> "$GITHUB_OUTPUT" + echo "Prompt-artifact drift detected:" + git status --short -- $paths + fi + + - name: Create pull request for regenerated prompt artifacts + if: steps.changes.outputs.changed == 'true' + uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v7.0.6 + with: + token: ${{ github.token }} + branch: chore/sync-prompt-artifacts + delete-branch: true + title: 'chore: sync prompt artifacts from upstream prompts.yml' + commit-message: 'chore: sync prompt artifacts from upstream prompts.yml' + body: | + Regenerates the committed prompt artifacts from react_on_rails `prompts.yml` + so the `prepare:prompts` build guard stays green. + + These files are generated by `npm run prepare:prompts`; do not edit by hand. + + Opened automatically by the `Sync upstream prompt artifacts` workflow. + add-paths: | + prototypes/docusaurus/src/constants/prompts.ts + prototypes/docusaurus/static/prompts.json + prototypes/docusaurus/static/prompts/llms.txt