Skip to content

Add merge drivers to staging-auto-merge and a maintain-staging reusable workflow #minor - #50

Draft
kylesmile wants to merge 1 commit into
mainfrom
staging-merge-drivers
Draft

kylesmile wants to merge 1 commit into
mainfrom
staging-merge-drivers

Conversation

@kylesmile

@kylesmile kylesmile commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Why

Two pull requests labeled Staging that each add a migration both change the define(version: …) line in db/schema.rb, so rebuilding staging drops the second one even though the fix is obvious: keep the newest version. Handling it in the action keeps the fix in one place for every app.

The action shouldn't assume a Rails app, so drivers are opt-in on the action and configurable: built-in drivers by name, custom ones with their own script, or both. The ability to specify custom drivers opens up experimentation without needing to modify the base action.

Changes

  • merge-drivers input on staging-auto-merge, a YAML list. Each entry is the name of a built-in driver, or a mapping with name, files (a pattern or list of patterns) and script. A built-in driver given as a mapping takes files to apply it to other files. The action rejects unknown built-in names, duplicate names, custom drivers that reuse a built-in name, and unknown keys. Default: none.
  • railsschema, the only built-in driver so far (staging-auto-merge/drivers/railsschema). It sets the define(version: …) line to the newest of base, ours, and theirs, then runs git merge-file, so a real schema conflict still fails with conflict markers and the pull request gets the usual comment.
  • Before merging, the action writes custom scripts to RUNNER_TEMP and registers every driver in .git/info/attributes and the checkout's git config, so nothing is committed to staging. git merge --squash uses the drivers.
  • .github/workflows/maintain-staging.yml, a reusable workflow holding the trigger filter, one-at-a-time concurrency, the checkout with a deploy key, and the action call. Inputs: primary-branch (default main), merge-drivers (default railsschema; pass [] for none), and runner (default ubuntu-latest). Secret: deploy-key.
  • Adds the yaml package to parse the input, which is why dist/index.js grew.
  • README documents the input, the drivers, and the reusable workflow.

Changelog

  • staging-auto-merge takes a merge-drivers input for git merge drivers: built-in ones by name (railsschema resolves db/schema.rb version conflicts) and custom ones with their own script.
  • New maintain-staging.yml reusable workflow rebuilds the staging branch with staging-auto-merge, using the railsschema driver by default.

Tests

  • tests/merge-drivers.test.js parses valid and invalid inputs, and runs real git merge --squash merges through drivers the action registers: the version-only conflict fails without a driver and merges with railsschema whichever side holds the newest version; a real schema conflict stops with markers around only that conflict; registering commits nothing; a custom driver runs alongside railsschema.
  • npm test passes (23 tests) and npm run build leaves dist/ unchanged.
  • The reusable workflow can only run from a caller; Add staging branch automation to the github generator rolemodel_rails#231 will add one through the github generator.

🤖 Generated with Claude Code

…le workflow

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant