Skip to content

Fix branch deletion failure when prior PR is merged - #13

Draft
bosconi wants to merge 3 commits into
mainfrom
jc/agent-skills
Draft

Fix branch deletion failure when prior PR is merged#13
bosconi wants to merge 3 commits into
mainfrom
jc/agent-skills

Conversation

@bosconi

@bosconi bosconi commented May 4, 2026

Copy link
Copy Markdown
Member

Problem

After a PR on automated/update-materialize-docs-skill is merged, branch protection prevents deletion of that branch. On the next workflow run, the "Set up branch" step found no open PR and tried git push origin --delete — which failed with GH013: Cannot delete this branch... push declined due to repository rule violations. Example failure: https://github.com/MaterializeInc/agent-skills/actions/runs/25344850407/job/74311218864

Fix

  • "Set up branch" step: Replace the delete-then-recreate logic with git checkout -B "$BRANCH" origin/main, which resets the local branch from main without touching the remote.
  • "Commit and push" step: Change git push origin "$BRANCH" to git push --force origin "$BRANCH", which overwrites the stale remote ref without needing to delete it first. Only the workflow writes to this branch, so force-push is safe.

Follow-up

After merge, the workflow should be manually re-run (or will trigger on next auto-detect) to regenerate the skill against v26.22.0.

bosconi and others added 3 commits April 28, 2026 16:25
When `mz_version` input is empty, the workflow now reads level-2 version
headings from doc/user/content/releases/_index.md on materialize@main,
takes the highest, and compares against the version recorded in the
heading of skills/materialize-docs/README.md. It only regenerates when
the upstream release is strictly newer, and updates the README heading
to the new version after a successful auto-bump.

The PR is created non-draft, and explicit `mz_version` invocations
still bypass version-checking and leave the README heading alone.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When the workflow is dispatched on a feature branch via
`gh workflow run --ref <branch>`, actions/checkout would otherwise
default to that branch's tree. The auto-bump PR then inherits the
feature-branch changes (e.g. the workflow file itself). Pin the
checkout to the default branch so test runs and production runs both
produce auto-bump PRs that contain only generated content.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Branch protection forbids deleting `automated/update-materialize-docs-skill`,
so `git push origin --delete` fails on the next run after a PR merges. Instead,
reset the branch locally from origin/main and force-push, which overwrites the
stale remote ref without needing to delete it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bosconi
bosconi requested review from def- and sjwiesman May 5, 2026 16:57

@def- def- left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Most of the changes in this PR seem unrelated to the stated "Fix branch deletion failure when prior PR is merged" title to me, is that intentional? Maybe I'm missing something.

In order to prevent the branch deletion failures couldn't we just use unique branch names or set the repository/user to auto-delete branches of PRs after they are merged?

git add skills/materialize-docs
git commit -m "Update materialize-docs skill from materialize@${MZ_REF}"
git push origin "$BRANCH"
git push --force origin "$BRANCH"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should always use force-with-lease, otherwise you risk overwriting changes made by someone else

persist-credentials: false

- name: Checkout MaterializeInc/materialize @ ${{ inputs.mz_version }}
- name: Determine target version

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seeing this much logic in a github action scares me. Can't this live in a Python script and we just run: that_script.py?

inputs:
mz_version:
description: 'Materialize ref (tag, branch, or commit SHA). Defaults to main.'
description: 'Materialize ref (tag, branch, or commit SHA). Leave empty to auto-detect the latest release.'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It might also be interesting to be able to test-run the docs update before actually having a release out? In my ideal world we would update docs immediately when a PR merges into main, but tag them with the version of Materialize required for this feature.

@bosconi
bosconi marked this pull request as draft May 17, 2026 23:29
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.

2 participants