ci(forgejo): add weekly upstream-sync workflow (#8) #38

Merged
jmz merged 166 commits from feat/upstream-sync-action into main 2026-10-31 13:00:52 +00:00
Owner

Adds .forgejo/workflows/upstream-sync.yml — a weekly (Mondays 04:17 UTC) + manually-dispatchable job that keeps the fork in sync with upstream.

What it does: fetches open-wanderer/wanderer main, and if the fork's base branch is behind, pushes a dated upstream-sync/<date> branch (pointing at upstream) and opens a PR into main. Merging is left to a human via the PR, so Forgejo surfaces any conflicts in the PR view (divergence stays small under upstream-first, so conflicts should be rare).

Why .forgejo/ not .github/: the .github/ workflows are shared with upstream; a pull-from-upstream job is fork-specific, so keeping it in .forgejo/ avoids diverging the shared files and it won't run on the upstream GitHub repo.

Requirements / notes:

  • Actions enabled on the repo with a runner on the ubuntu-latest label (same as the existing .github workflows).
  • The automatic Actions token must be allowed to push branches + create PRs (repo-scoped default). If PR creation is forbidden, set a PAT secret and swap ${{ github.token }} in the Open sync PR step.

Validation: YAML parses; all embedded run: scripts pass bash -n; the core git logic (fetch upstream, rev-list --count, branch-from-upstream/main, and the ls-remote idempotency guard) was dry-run locally against this repo (base is currently 1 commit behind upstream). Actions runtime itself not executed here.

Closes #8. Prepared during holiday-autopilot — not merged.

Adds `.forgejo/workflows/upstream-sync.yml` — a weekly (Mondays 04:17 UTC) + manually-dispatchable job that keeps the fork in sync with upstream. **What it does:** fetches `open-wanderer/wanderer` `main`, and if the fork's base branch is behind, pushes a dated `upstream-sync/<date>` branch (pointing at upstream) and opens a PR into `main`. Merging is left to a human via the PR, so Forgejo surfaces any conflicts in the PR view (divergence stays small under upstream-first, so conflicts should be rare). **Why `.forgejo/` not `.github/`:** the `.github/` workflows are shared with upstream; a pull-from-upstream job is fork-specific, so keeping it in `.forgejo/` avoids diverging the shared files and it won't run on the upstream GitHub repo. **Requirements / notes:** - Actions enabled on the repo with a runner on the `ubuntu-latest` label (same as the existing `.github` workflows). - The automatic Actions token must be allowed to push branches + create PRs (repo-scoped default). If PR creation is forbidden, set a PAT secret and swap `${{ github.token }}` in the *Open sync PR* step. **Validation:** YAML parses; all embedded `run:` scripts pass `bash -n`; the core git logic (fetch upstream, `rev-list --count`, branch-from-`upstream/main`, and the `ls-remote` idempotency guard) was dry-run locally against this repo (base is currently 1 commit behind upstream). Actions runtime itself not executed here. Closes #8. Prepared during holiday-autopilot — **not merged**.
jmz force-pushed feat/upstream-sync-action from 48383b6af4 to 5d4c9bcc2f
Some checks failed
CI / go (push) Has been cancelled
CI / web (push) Has been cancelled
2026-10-30 23:34:32 +00:00
Compare
maximus changed target branch from main to main-v0.21.2 2026-10-30 23:34:47 +00:00
Member

Phase-1 catch-up review (upstream v0.21.2)

Rebased onto main-v0.21.2, with the base retargeted. The old head is kept as archive/feat-upstream-sync-action-pre-v0.21.2. I added 5d4c9bcc to make it runnable on our runner and safe for our branches:

  • Runner: runs-on: docker, actions/checkout@v4, and apt-installed git/jq/curl. The node-with-docker job image has no git or jq and runs as root, so sudo would fail. This is the same setup as ci.yml (forgejo-runner v12 on the NAS). The original ubuntu-latest + checkout@v7 + sudo apt-get would have broken on the missing git/jq and on sudo.
  • Cannot clobber branches:
    • It only ever pushes a new refs/heads/upstream-sync/<date> (the name is checked), with no --force.
    • An existing sync branch means "do nothing".
    • main and deploy are never written; merging stays a human PR decision.
  • Better sync branch:
    • It is main plus a merge of upstream. The branch keeps .forgejo/, so our CI runs on it and not upstream's .github release workflows, and the PR is a fast-forward for main.
    • On a conflict it falls back to the raw upstream commit, and the PR body says to resolve it in a local merge branch.
  • Other:
    • workflow_dispatch input dry_run.
    • The PR title names the upstream tag.
    • An optional SYNC_TOKEN secret.
    • The token is passed in a header file, not argv.
    • The PR body reminds you to merge into deploy on a new branch and to back up pb_data first when there are migrations.

Open questions / before merging:

  1. Untested at runtime. A dry_run=true dispatch (run 12824) was queued and then cancelled with the rest of tonight's CI. Run it in a quiet window.
  2. Branch protection: please protect main and deploy (no force push, push restricted to jmz). maximus can't read or set protections. This is the real guarantee; the workflow only adds a second layer.
  3. Actions-token pushes may not trigger CI. Forgejo skips workflow runs for events caused by the automatic Actions token, so CI may not start on the sync branch. If that happens, set SYNC_TOKEN (a PAT of a write collaborator) and check the first run.
  4. Schedule:
    • The fork's runner is a capacity-1 container on the NAS, and a sync branch triggers the full go+web CI (about 25 min of NAS load).
    • The cron (17 4 * * 1) sits next to Renovate (04:30 daily) and the night backups.
    • Move it to a confirmed quiet slot before merging.

Verdict: merge after (1) a green dry run and (2) the branch protections are set. Closes #8.

🤖 Generated with Claude Code

https://claude.ai/code/session_01M1AaXnEghenJ4BDxNryKvs

## Phase-1 catch-up review (upstream v0.21.2) **Rebased** onto `main-v0.21.2`, with the base retargeted. The old head is kept as `archive/feat-upstream-sync-action-pre-v0.21.2`. I added `5d4c9bcc` to make it runnable on our runner and safe for our branches: - **Runner:** `runs-on: docker`, `actions/checkout@v4`, and apt-installed git/jq/curl. The node-with-docker job image has no git or jq and runs as root, so `sudo` would fail. This is the same setup as `ci.yml` (forgejo-runner v12 on the NAS). The original `ubuntu-latest` + `checkout@v7` + `sudo apt-get` would have broken on the missing git/jq and on `sudo`. - **Cannot clobber branches:** - It only ever pushes a *new* `refs/heads/upstream-sync/<date>` (the name is checked), with no `--force`. - An existing sync branch means "do nothing". - `main` and `deploy` are never written; merging stays a human PR decision. - **Better sync branch:** - It is `main` plus a merge of upstream. The branch keeps `.forgejo/`, so our CI runs on it and not upstream's `.github` release workflows, and the PR is a fast-forward for `main`. - On a conflict it falls back to the raw upstream commit, and the PR body says to resolve it in a local merge branch. - **Other:** - `workflow_dispatch` input `dry_run`. - The PR title names the upstream tag. - An optional `SYNC_TOKEN` secret. - The token is passed in a header file, not argv. - The PR body reminds you to merge into `deploy` on a new branch and to back up pb_data first when there are migrations. **Open questions / before merging:** 1. **Untested at runtime.** A `dry_run=true` dispatch (run 12824) was queued and then cancelled with the rest of tonight's CI. Run it in a quiet window. 2. **Branch protection:** please protect `main` and `deploy` (no force push, push restricted to jmz). maximus can't read or set protections. This is the real guarantee; the workflow only adds a second layer. 3. **Actions-token pushes may not trigger CI.** Forgejo skips workflow runs for events caused by the automatic Actions token, so CI may not start on the sync branch. If that happens, set `SYNC_TOKEN` (a PAT of a write collaborator) and check the first run. 4. **Schedule:** - The fork's runner is a capacity-1 container on the NAS, and a sync branch triggers the full go+web CI (about 25 min of NAS load). - The cron (`17 4 * * 1`) sits next to Renovate (04:30 daily) and the night backups. - Move it to a confirmed quiet slot before merging. **Verdict: merge after (1) a green dry run and (2) the branch protections are set.** Closes #8. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01M1AaXnEghenJ4BDxNryKvs
CI runs on a capacity-1 runner on the NAS and only had a push trigger.
Pushes made with the automatic Actions token (the upstream-sync branch)
do not start workflows, and CI often has to wait for a quiet window, so
add workflow_dispatch to run it on any branch on demand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01M1AaXnEghenJ4BDxNryKvs
ci(forgejo): move upstream sync to Sunday 03:10 UTC, add a local dry run
All checks were successful
CI / go (push) Successful in 26m37s
CI / web (push) Successful in 2m7s
96295b75c5
- Schedule: Sunday 03:10 UTC instead of Monday 04:17, which collided
  with mail-archive-gmail (04:17) and sat next to Renovate (04:30) and
  the 03:30-04:30 backup jobs on the NAS that also hosts the runner.
- Document the token model: the branch push uses the automatic token
  (so it does not start CI at night); SYNC_TOKEN is optional and only
  for the PR API call if the automatic token is refused.
- Add .forgejo/scripts/upstream-sync-dry-run.sh: shows the behind count,
  the branch and PR it would create, conflicting files (git merge-tree,
  no worktree) and the incoming commits, in a throwaway bare repo,
  without pushing anything.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01M1AaXnEghenJ4BDxNryKvs
jmz changed target branch from main-v0.21.2 to main 2026-10-31 13:00:48 +00:00
jmz merged commit 96295b75c5 into main 2026-10-31 13:00:52 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
public/wanderer!38
No description provided.