fix(ci): repair merge-back workflow #3

Merged
ComputerCrack merged 3 commits from feature/netoskur-5mg-fix-merge-back-workflow into develop 2026-10-11 01:09:37 +00:00

Summary

Repairs .gitea/workflows/sync-develop.yml. The approval step was still on develop, because PR #1 was merged before the removal commit arrived.

 on(push main)
+  concurrency group sync-develop, temp dir via mktemp, curl --max-time 30, token via header file
+  GET compare/develop...main: total_commits 0 -> exit green "nothing to merge"
-  open PR "Merge main into develop"
+  open PR "chore(sync): merge main into develop"        -> log "opened PR #n"
-  409: take PR number blindly
+  409: GET /pulls/develop/main, require HTTP 200 + state open -> log "reusing open PR #n"
-  422: exit green silently                               (wrong: Forgejo creates an EMPTY PR instead of 422)
+  422 / anything else: print body, exit red
+  mktemp failure: exit red
-  approve PR via API                                     (fails: self-approval)
   merge PR via API, retry on 405, else exit red and leave PR open
-  permissions block (unused)

Refs: Netoskur-5mg

Evidence

  • Before: develop (5fc0c74) contains the APPROVED review call (lines 55-61). Every run would exit 1 there.
    After: no approval call. Verified on this instance: an in-sync PR request creates an empty PR (test PR #4, closed), the compare API returns total_commits, pulls/{base}/{head} returns open PRs, and the JSON is compact. The YAML parses, and bash -n on the extracted run script passes. Not run yet: the first real run happens when release PR #2 is merged into main.

Merge Danger

Door: two-way

Only CI config changes. Reverting restores the previous file.

Blast Radius: develop

The merge-back writes to develop only. With a missing or expired SYNC_TOKEN, it fails red without side effects.

## Summary Repairs `.gitea/workflows/sync-develop.yml`. The approval step was still on `develop`, because PR #1 was merged before the removal commit arrived. ```diff on(push main) + concurrency group sync-develop, temp dir via mktemp, curl --max-time 30, token via header file + GET compare/develop...main: total_commits 0 -> exit green "nothing to merge" - open PR "Merge main into develop" + open PR "chore(sync): merge main into develop" -> log "opened PR #n" - 409: take PR number blindly + 409: GET /pulls/develop/main, require HTTP 200 + state open -> log "reusing open PR #n" - 422: exit green silently (wrong: Forgejo creates an EMPTY PR instead of 422) + 422 / anything else: print body, exit red + mktemp failure: exit red - approve PR via API (fails: self-approval) merge PR via API, retry on 405, else exit red and leave PR open - permissions block (unused) ``` Refs: Netoskur-5mg ## Evidence - **Before:** `develop` (5fc0c74) contains the `APPROVED` review call (lines 55-61). Every run would exit 1 there. **After:** no approval call. Verified on this instance: an in-sync PR request creates an empty PR (test PR #4, closed), the compare API returns `total_commits`, `pulls/{base}/{head}` returns open PRs, and the JSON is compact. The YAML parses, and `bash -n` on the extracted run script passes. Not run yet: the first real run happens when release PR #2 is merged into `main`. ## Merge Danger **Door:** two-way Only CI config changes. Reverting restores the previous file. **Blast Radius:** develop The merge-back writes to `develop` only. With a missing or expired `SYNC_TOKEN`, it fails red without side effects.
Signed-off-by: Jonathan Schmidt <kontakt@jonathan-schmidt.de>
Signed-off-by: Jonathan Schmidt <kontakt@jonathan-schmidt.de>
Signed-off-by: Jonathan Schmidt <kontakt@jonathan-schmidt.de>
ComputerCrack deleted branch feature/netoskur-5mg-fix-merge-back-workflow 2026-10-11 01:09:37 +00:00
Author
Owner

Agent review 1 (code-review, fresh agent) on e31de50: approve with changes

  1. Medium: the JSON greps assume compact JSON. Verified on this instance: the API returns compact JSON.
  2. Medium: 422 was treated as "in sync". Fixed in 221d9d1: Forgejo creates an empty PR instead of returning 422 (test PR #4, closed). The workflow now checks compare/develop...main first, and any 422 exits red.
  3. Medium: "block merge if outdated" on develop would block the merge-back after hotfixes. Resolved: the setting is disabled on develop (decision Netoskur-581.24).
  4. Low: concurrency support is unverified. It is harmless if ignored.
  5. Low: a real conflict also returns 405 and burns 60 s of retries. The PR stays open, which is correct.
  6. Low: a mktemp failure is unguarded. Fixed in 221d9d1.

Clean: no token leakage (header file in a 0700 temp dir, removed by the trap), curl -H @file, set -u handling, and pulls/{base}/{head} (verified on this instance).

Agent review 2 on 221d9d1 (fresh agent): approve

  • Low: the second mktemp guard was redundant. Removed in 33f2588.
  • Low: the total_commits grep expects compact JSON. It fails red otherwise.
  • Unverified by agent, verified on this instance: compare/develop...main counts the commits on main that are missing on develop (0 versus 1 in reverse).

Standards: no comments, English, scoped titles. Spec Netoskur-5mg: all items met.

## Agent review 1 (code-review, fresh agent) on e31de50: approve with changes 1. **Medium:** the JSON greps assume compact JSON. **Verified on this instance:** the API returns compact JSON. 2. **Medium:** 422 was treated as "in sync". **Fixed in 221d9d1:** Forgejo creates an empty PR instead of returning 422 (test PR #4, closed). The workflow now checks `compare/develop...main` first, and any 422 exits red. 3. **Medium:** "block merge if outdated" on `develop` would block the merge-back after hotfixes. **Resolved:** the setting is disabled on `develop` (decision Netoskur-581.24). 4. **Low:** `concurrency` support is unverified. It is harmless if ignored. 5. **Low:** a real conflict also returns 405 and burns 60 s of retries. The PR stays open, which is correct. 6. **Low:** a `mktemp` failure is unguarded. **Fixed in 221d9d1.** Clean: no token leakage (header file in a 0700 temp dir, removed by the trap), `curl -H @file`, `set -u` handling, and `pulls/{base}/{head}` (verified on this instance). ## Agent review 2 on 221d9d1 (fresh agent): approve - **Low:** the second `mktemp` guard was redundant. **Removed in 33f2588.** - **Low:** the `total_commits` grep expects compact JSON. It fails red otherwise. - **Unverified by agent, verified on this instance:** `compare/develop...main` counts the commits on `main` that are missing on `develop` (0 versus 1 in reverse). Standards: no comments, English, scoped titles. Spec Netoskur-5mg: all items met.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
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
ComputerCrack/Netoskur!3
No description provided.