Repository navigation
Conversation
OutlawAndy
left a comment
There was a problem hiding this comment.
Thanks for picking this up. The db/schema.rb version conflict has dropped PRs from staging more than once, and the driver's approach of taking the newest version and then running a normal git merge-file is right. I'd like to move most of it into RoleModel/actions instead of generating it into every app, so it's maintained in one place and existing apps get it too.
The merge driver goes in staging-auto-merge. The action already runs the git merge --squash that hits the conflict, so it can register the driver itself before merging: write db/schema.rb merge=railsschema to .git/info/attributes and set merge.railsschema.driver to a script that ships with the action. Neither of those is committed, and --squash still uses the driver. I tested this in a scratch repo: the same two-migration conflict fails without the driver and merges cleanly to the newest version with it. That means:
- apps don't get
bin/schema-merge,bin/setup-schema-mergeor a.gitattributesentry - every app already using
staging-auto-mergegets the fix with its next actions version bump, with no regenerating - your real-git specs move to the action's
tests/, next to the code they test
The rebuild job becomes a reusable workflow: RoleModel/actions/.github/workflows/maintain-staging.yml, like rails-ci.yml and release.yml. The trigger filter, concurrency, checkout with the deploy key and the action call all go there. Each app keeps only a short caller, which is the part the github generator should add:
name: Maintain Staging Branch
on:
pull_request:
types: [labeled, unlabeled, closed, synchronize]
jobs:
staging:
uses: RoleModel/actions/.github/workflows/maintain-staging.yml@v3
permissions:
contents: write
issues: write
pull-requests: write
with:
primary-branch: main
secrets:
deploy-key: ${{ secrets.AUTOMATED_COMMITS_KEY }}The caller has to grant every permission the reusable job declares. If it grants less, the run fails at startup with no logs.
I'd drop running the driver locally. The conflict comes from rebuilding staging, which only happens in CI. If someone hits it locally, they can add it then.
That leaves this PR with the caller template, the --primary-branch option, and the README notes on the Staging label, the staging branch and the AUTOMATED_COMMITS_KEY secret, which are all good as they are. Happy to pair on the actions side if that helps.
|
@OutlawAndy Yes, I think it makes sense to move some things up to the actions repo. I want to be careful about introducing Rails-specific steps to the |
…nerator Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The schema.rb merge driver and the staging rebuild job now live in RoleModel/actions, so the generator no longer adds bin/schema-merge, bin/setup-schema-merge or a .gitattributes entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d8f2982 to
a065de4
Compare
|
@OutlawAndy Updated this PR, and opened RoleModel/actions#50. I still need to go through both for cleanup before they're entirely ready. |
Why?
Two pull requests labeled
Stagingthat each add a migration both change thedefine(version: …)line indb/schema.rb. When the staging branch is rebuilt, that conflict drops the second pull request even though the fix is obvious: keep the newest version.The fix and the rebuild job live in RoleModel/actions#50:
staging-auto-mergetakes amerge-driversinput with a built-inrailsschemadriver, and themaintain-staging.ymlreusable workflow uses it by default. This PR has thegithubgenerator add a short caller of that workflow, so new apps start with staging automation.What Changed
maintain-staging.ymlcallsRoleModel/actions/.github/workflows/maintain-staging.ymlat the same major version as CI. It grants the permissions the reusable job declares and passes theAUTOMATED_COMMITS_KEYdeploy key, so the push tostagingstartsdeploy-staging.yml.--primary-branchoption (defaultmain) for the branch staging is rebuilt from--primary-branchoptionPre-merge checklist
stagingbranch, aStaginglabel, the deploy key secret), says the workflow uses therailsschemamerge driver, and saysdeploy-staging.ymlruns on pushes tostaging.Notes
Please don't commit version changes within your PR. Versioning, releasing, and changelog entries are managed through the Release workflow.
Screenshots
No UI changes.
🤖 Generated with Claude Code