Skip to content

ci: weekly upstream sync with auto-merge, build image on main - #16

Merged
bateman merged 5 commits into
mainfrom
claude/upstream-updates-merge-odi6sy
Oct 19, 2026
Merged

bateman merged 5 commits into
mainfrom
claude/upstream-updates-merge-odi6sy

Conversation

@bateman

@bateman bateman commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Fork-only automation for keeping bateman/unpackerr in sync with Unpackerr/unpackerr and publishing the container image.

upstream-sync.yml (new)

  • Runs Fridays at 14:00 Europe/Rome (timezone: on the schedule, so it follows DST), and can also be started by hand with workflow_dispatch. It is skipped on Unpackerr/unpackerr.
  • If upstream main has new commits, it pushes them to sync/upstream and opens a PR to main, or updates the one already open.
  • It waits for GitHub to compute mergeability on the new head, then for the REQUIRED_CHECKS (gotest (ubuntu), golangci-lint (linux), integration) to appear and pass. It then merges with a merge commit (--match-head-commit) and deletes sync/upstream.
  • If the PR has conflicts, it comments once and leaves the PR open. If CI fails or a required check never appears, the PR also stays open. In all these cases the run fails, so GitHub sends an email.
  • sync/upstream is never overwritten while it carries an unmerged conflict fix. A leftover branch that was already merged into main is replaced (--force-with-lease). Any push or remote error fails the run.
  • The workflow waits for CI itself instead of using native auto-merge, so it needs no branch protection or "Allow auto-merge" setting.
  • It requires the UPSTREAM_SYNC_TOKEN secret: a fine-grained PAT for this repo with Contents, Pull requests and Workflows set to read/write. The default GITHUB_TOKEN can't push upstream's workflow-file changes, and its pushes don't trigger CI.

fork.yml

  • Also builds and pushes the GHCR image on pushes to main, tagged :main alongside :sha-…. :latest is still published only from v* tags.
  • Has a concurrency group per event and ref, so an older build can't overwrite :main and a manual run doesn't cancel a build started by a push.

Validation

  • actionlint and shellcheck report no issues on both files.
  • The sync branch logic was tested against local test repos in six cases: up to date, new upstream commits, a re-run, keeping an unmerged conflict fix, replacing a leftover branch that was already merged, and a rejected push (which fails the run).
  • Two code-review passes were applied; see the commit messages.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kzh7gFueN8WPtT59UZzXKB

Add upstream-sync.yml (fork-only): every Monday it pushes
Unpackerr/unpackerr main to sync/upstream, opens or updates a PR to
main, waits for CI and merges it when green. Conflicts or red CI leave
the PR open and fail the run. Requires the UPSTREAM_SYNC_TOKEN secret.

fork.yml now also builds and pushes the GHCR image on pushes to main,
tagged :main (plus :sha-...); :latest stays reserved for v* tags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kzh7gFueN8WPtT59UZzXKB
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kzh7gFueN8WPtT59UZzXKB
- Never force-push sync/upstream, so a conflict fix made on the open PR
  survives the next run; merge against the branch's real head SHA.
- Only CONFLICTING is reported as a conflict, and the PR is commented
  once; an UNKNOWN mergeability just fails the run.
- Check-registration loop no longer trips over pipefail.
- Take the PR number from gh pr create's URL instead of re-listing.
- Use gh pr merge --delete-branch instead of a manual remote delete.
- fork.yml: per-ref concurrency so an older build cannot overwrite :main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kzh7gFueN8WPtT59UZzXKB
- Classify sync/upstream before pushing: keep it only when it carries
  unmerged non-upstream commits; replace a leftover branch already merged
  into main (with --force-with-lease); any push or remote error now fails
  the run instead of being mistaken for a conflict fix.
- Wait for mergeability computed on this run's head SHA, not a cached
  value from the previous head.
- Wait for the named REQUIRED_CHECKS to appear before watching CI, and
  report missing checks separately from failing ones.
- Only rewrite the PR title/body (and sleep for check registration) when
  the branch actually moved.
- fork.yml: concurrency per event and ref, so a manual run no longer
  cancels a push build; the branch tag is only published for main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kzh7gFueN8WPtT59UZzXKB
@bateman
bateman merged commit fc9ea8d into main Oct 19, 2026
4 checks passed
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