Skip to content
Hands-on IT IT Drills

Day 5: Automerge and Status Checks

Goal: You let Renovate merge low-risk updates by itself and know exactly which status check triggers or prevents a merge, and when. · Duration: approx. 100 min · Prerequisite: Day 4

Briefing

  • automerge: true does not mean “merge immediately”, but: merge as soon as all commit statuses of the branch are success. No status counts as “pending”.
  • Renovate is not a daemon. It merges only during a run. Between two runs nothing happens, unless Forgejo takes over (platformAutomerge).
  • automergeType: "pr" (default) merges a PR, "branch" pushes directly to main. Then there is only a PR if something goes wrong.
  • Today you play the CI yourself: you set commit statuses via the Forgejo API.
 Run n     create branch (+ PR) ──► CI sets status on the commit, e.g. ci/test
 Run n+1   read status: all success ──► merge (pr: PR merge, branch: push to main)
                         pending/none ──► wait          failure ──► do not merge
 platformAutomerge: Forgejo merges by itself as soon as the checks are green (no run)

Drill 1: Training ground and helpers

Today you set up shop-api fresh several times, each time with a different renovate.json from the companion code. Each time this includes: new repo, Forgejo Actions turned off in the repo, config on main. Your “CI” is you: a commit status is a POST /repos/{owner}/{repo}/statuses/{sha} with state and context – exactly the call a real CI server makes.

source ~/renovate-lab/setup/env.sh
export RENOVATE_GITHUB_COM_TOKEN=$(gh auth token)   # optional, see Day 0
mkdir -p ~/renovate-lab/tag05 && cd ~/renovate-lab/tag05
API="$FORGEJO/api/v1/repos/shop/shop-api"

Why turn Actions off? Forgejo 16 runs .github/workflows/ci.yml as Forgejo Actions. Without a runner, the checks ci / test (push) and ci / test (pull_request) stay pending forever (observed like this in the test). First lesson: a single foreign check that never finishes holds up every automerge.

The first config: Renovate merges patch and minor updates of devDependencies by itself. enabledManagers (Day 3) and prHourlyLimit: 0 (Day 4) keep the picture small.

cat > automerge.json <<'EOF'
{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "extends": ["config:recommended"],
  "enabledManagers": ["npm"],
  "prHourlyLimit": 0,
  "packageRules": [
    {
      "description": "devDependencies: patch und minor automatisch mergen",
      "matchDepTypes": ["devDependencies"],
      "matchUpdateTypes": ["patch", "minor"],
      "automerge": true
    }
  ]
}
EOF
curl -s -o /dev/null -w '%{http_code}\n' -u "$ADMIN" -X DELETE "$API"
git -C ~/renovate-lab/shop-api push -q forgejo:shop/shop-api.git main
curl -s -u "$ADMIN" -X PATCH --json '{"has_actions":false}' "$API" | jq .has_actions
rm -rf shop-api
git clone -q forgejo:shop/shop-api.git
cp automerge.json shop-api/renovate.json
git -C shop-api add renovate.json
git -C shop-api commit -qm "Renovate-Konfiguration"
git -C shop-api push -q
curl -s -u "$ADMIN" "$API" | jq -c '{has_actions, default_branch}'

Expected:

{"has_actions":false,"default_branch":"main"}

Save your progress? Sign up for free

Drill 2: automerge with platformAutomerge – Forgejo merges

The first run with the default platformAutomerge: true:

LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'INFO|automerge' auszug.log | cut -c1-88
curl -s -u "$ADMIN" "$API/pulls" \
  | jq -r '.[] | "#\(.number) \(.state) \(.head.ref) | \(.title)"'
curl -s -u "$ADMIN" "$API/issues/2/timeline" | jq -r '.[] | "\(.type) (\(.user.login))"'
curl -s -u "$ADMIN" "$API/pulls/2" | jq -r .body | grep 'Automerge\*\*'

Expected (your target versions will be newer):

[prettier-3.x] DEBUG: Converting rebaseWhen=auto to rebaseWhen=behind-base-branch becaus
[prettier-3.x] INFO: Branch created
[prettier-3.x] DEBUG: Forgejo-native automerge: success
[prettier-3.x] INFO: PR created
[prettier-3.x] DEBUG: Skipping assignees and reviewers as automerge=true
[prettier-3.x] DEBUG: PR is configured for automerge
#1 open renovate/express-4.x | Update dependency express to v4.22.3
#2 open renovate/prettier-3.x | Update dependency prettier to v3.9.10
#3 open renovate/express-5.x | Update dependency express to v5
pull_push (renovate-bot)
pull_scheduled_merge (renovate-bot)
🚦 **Automerge**: Enabled.

Only prettier is a devDependency, so only PR #2 is marked for automerge. Right after creating it, Renovate asked Forgejo via the API to merge the PR as soon as the checks are green (merge_when_checks_succeed, Forgejo 10 and later). The timeline shows this as pull_scheduled_merge. Now your “CI” reports: test red, linter green. There is no Renovate run in between.

curl -s -u "$ADMIN" "$API/commits/renovate%2Fprettier-3.x/status" | jq -r .state
curl -s -u "$ADMIN" "$API/commits/renovate%2Fprettier-3.x/status" \
  | jq -r '.statuses[] | "\(.context) = \(.status)"'
SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fprettier-3.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"failure","context":"ci/test"}' | jq -r .status
sleep 5; curl -s -u "$ADMIN" "$API/pulls?state=all" \
  | jq -r '.[] | "#\(.number) \(.state) \(.head.ref) | \(.title)"' | grep prettier
SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fprettier-3.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"success","context":"ci/lint"}' | jq -r .status
sleep 5; curl -s -u "$ADMIN" "$API/pulls?state=all" \
  | jq -r '.[] | "#\(.number) \(.state) \(.head.ref) | \(.title)"' | grep prettier
curl -s -u "$ADMIN" "$API/commits?sha=main&limit=2" \
  | jq -r '.[].commit.message | split("\n")[0]'

Expected:


failure
#2 open renovate/prettier-3.x | Update dependency prettier to v3.9.10
success
#2 merged renovate/prettier-3.x | Update dependency prettier to v3.9.10
b1c85ee Merge pull request 'Update dependency prettier to v3.9.10' (#2) from ren
ecc769c Update dependency prettier to v3.9.10

With no status and with failure, Forgejo waited. The first success triggered the merge, even though ci/test is red. Forgejo merges and deletes the branch; Renovate was not involved. Without branch protection, Forgejo knows no required checks and apparently does not check other red checks for the scheduled merge. “Wait without a status” is not reliable either: if Renovate pushes the branch again (rebase), Forgejo can execute the scheduled merge immediately, even before a check has reported (Day 15).

Warning: Use platformAutomerge (default true) on Forgejo only together with branch protection and required checks (Drill 8). With protection on ci/test, Forgejo correctly waited in the test until exactly that check was green.

Save your progress? Sign up for free

Drill 3: Renovate merges by itself – pending, failure, success

With platformAutomerge: false, Renovate checks the status itself. That way you see every state in the log.

jq '.platformAutomerge = false' automerge.json > automerge-renovate.json
curl -s -o /dev/null -w '%{http_code}\n' -u "$ADMIN" -X DELETE "$API"
git -C ~/renovate-lab/shop-api push -q forgejo:shop/shop-api.git main
curl -s -u "$ADMIN" -X PATCH --json '{"has_actions":false}' "$API" | jq .has_actions
rm -rf shop-api
git clone -q forgejo:shop/shop-api.git
cp automerge-renovate.json shop-api/renovate.json
git -C shop-api add renovate.json
git -C shop-api commit -qm "Renovate-Konfiguration"
git -C shop-api push -q
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'INFO|native' auszug.log | cut -c1-88
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'not ready|automerged' auszug.log | cut -c1-88

Expected:

[prettier-3.x] INFO: Branch created
[prettier-3.x] INFO: PR created
[prettier-3.x] DEBUG: PR is not ready for merge (branch status is yellow)

No more native on creation. In the second run there is no status yet: yellow. Now you play through the CI:

SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fprettier-3.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"pending","context":"ci/test"}' | jq -r .status
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'not ready|automerged' auszug.log | cut -c1-88
SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fprettier-3.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"failure","context":"ci/test"}' | jq -r .status
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'not ready|automerged' auszug.log | cut -c1-88
curl -s -u "$ADMIN" "$API/commits/renovate%2Fprettier-3.x/status" | jq -r .state
curl -s -u "$ADMIN" "$API/commits/renovate%2Fprettier-3.x/status" \
  | jq -r '.statuses[] | "\(.context) = \(.status)"'
SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fprettier-3.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"success","context":"ci/test"}' | jq -r .status
sleep 10; curl -s -u "$ADMIN" "$API/pulls" \
  | jq -r '.[] | "#\(.number) \(.state) \(.head.ref) | \(.title)"' | grep prettier
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'Automerging|automerged' auszug.log | cut -c1-88
curl -s -u "$ADMIN" "$API/pulls?state=all" \
  | jq -r '.[] | "#\(.number) \(.state) \(.head.ref) | \(.title)"' | grep prettier

Expected:

pending
[prettier-3.x] DEBUG: PR is not ready for merge (branch status is yellow)
failure
[prettier-3.x] DEBUG: PR is not ready for merge (branch status is red)
failure
ci/test = failure
success
#2 open renovate/prettier-3.x | Update dependency prettier to v3.9.10
[prettier-3.x] DEBUG: Automerging #2 with strategy auto
[prettier-3.x] INFO: PR automerged
#2 merged renovate/prettier-3.x | Update dependency prettier to v3.9.10

Forgejo reports unknown, pending, success, warning, failure, error. Renovate turns that into yellow (unknown, pending), green (success), or red (the rest). Per context, only the newest status counts, which is why success replaced the failure. Ten seconds after success, the PR was still open: only the next run merged it. The merge latency is therefore your run interval (Day 10).

Save your progress? Sign up for free

Drill 4: automergeType branch – to main without a PR

With automergeType: "branch", Renovate creates only the branch and waits for green CI. Then it pushes the commit directly to main.

jq '.packageRules[0].automergeType = "branch"' automerge-renovate.json \
  > automerge-branch.json
curl -s -o /dev/null -w '%{http_code}\n' -u "$ADMIN" -X DELETE "$API"
git -C ~/renovate-lab/shop-api push -q forgejo:shop/shop-api.git main
curl -s -u "$ADMIN" -X PATCH --json '{"has_actions":false}' "$API" | jq .has_actions
rm -rf shop-api
git clone -q forgejo:shop/shop-api.git
cp automerge-branch.json shop-api/renovate.json
git -C shop-api add renovate.json
git -C shop-api commit -qm "Renovate-Konfiguration"
git -C shop-api push -q
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'INFO|Branch automerge' auszug.log | cut -c1-88
curl -s -u "$ADMIN" "$API/pulls" \
  | jq -r '.[] | "#\(.number) \(.state) \(.head.ref) | \(.title)"'
curl -s -u "$ADMIN" "$API/branches" | jq -r '.[].name' | sort

Expected:

[prettier-3.x] INFO: Branch created
[prettier-3.x] DEBUG: Branch automerge is enabled
#1 open renovate/express-4.x | Update dependency express to v4.22.3
#2 open renovate/express-5.x | Update dependency express to v5
main
renovate/express-4.x
renovate/express-5.x
renovate/prettier-3.x

Branch yes, PR no. So your CI has to run on pushes to renovate/*, not only on pull requests. Now report green and wait for the next run:

SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fprettier-3.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"success","context":"ci/test"}' | jq -r .status
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'INFO|mergeStatus' auszug.log | cut -c1-88
curl -s -u "$ADMIN" "$API/commits?sha=main&limit=3" \
  | jq -r '.[].commit.message | split("\n")[0]'
curl -s -u "$ADMIN" "$API/commits?sha=main&limit=1" \
  | jq -r '.[0] | "\(.commit.author.name), Eltern: \(.parents | length)"'

Expected:

success
[prettier-3.x] INFO: Branch automerged
[prettier-3.x] DEBUG: mergeStatus=automerged
68f835c Update dependency prettier to v3.9.10
47f32fc Renovate-Konfiguration
e145fb9 Initialer Stand
Renovate Bot, Eltern: 1

No merge commit, no PR: Renovate fast-forwarded main to the update commit and deleted the branch (Eltern: 1 means one parent). With no status or with pending, you instead see Branch status is "yellow" - skipping automerge. The challenge shows what happens with failure.

Save your progress? Sign up for free

Drill 5: rebaseWhen – what a merge to main triggers

Back to PR mode. This time main changes after the CI has reported green.

curl -s -o /dev/null -w '%{http_code}\n' -u "$ADMIN" -X DELETE "$API"
git -C ~/renovate-lab/shop-api push -q forgejo:shop/shop-api.git main
curl -s -u "$ADMIN" -X PATCH --json '{"has_actions":false}' "$API" | jq .has_actions
rm -rf shop-api
git clone -q forgejo:shop/shop-api.git
cp automerge-renovate.json shop-api/renovate.json
git -C shop-api add renovate.json
git -C shop-api commit -qm "Renovate-Konfiguration"
git -C shop-api push -q
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'INFO' auszug.log | cut -c1-88
for b in express-4.x express-5.x prettier-3.x; do
  echo "$b $(sha renovate/$b | cut -c1-7)"; done
SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fprettier-3.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"success","context":"ci/test"}' | jq -r .status
cd shop-api && git pull -q && echo "Lab-Notiz" >> README.md \
  && git commit -qam "README ergänzen" && git push -q && cd ..
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E 'Converting|needs rebasing|INFO: Branch|automerged' lauf.log | cut -c1-88
for b in express-4.x express-5.x prettier-3.x; do
  echo "$b $(sha renovate/$b | cut -c1-7)"; done
curl -s -u "$ADMIN" "$API/commits/renovate%2Fprettier-3.x/status" | jq -r .state
curl -s -u "$ADMIN" "$API/commits/renovate%2Fprettier-3.x/status" \
  | jq -r '.statuses[] | "\(.context) = \(.status)"'

Expected (hashes differ):

[prettier-3.x] INFO: Branch created
[prettier-3.x] INFO: PR created
express-4.x e0129cd
express-5.x bd4093b
prettier-3.x 09fdd8a
success
[express-4.x] DEBUG: Converting rebaseWhen=auto to rebaseWhen=conflicted because no rule
[prettier-3.x] DEBUG: Converting rebaseWhen=auto to rebaseWhen=behind-base-branch becaus
[prettier-3.x] DEBUG: Branch is behind base branch and needs rebasing
[prettier-3.x] INFO: Branch updated
[express-5.x] DEBUG: Converting rebaseWhen=auto to rebaseWhen=conflicted because no rule
express-4.x e0129cd
express-5.x bd4093b
prettier-3.x 2176020

rebaseWhen is set to auto. For automerge branches, that becomes behind-base-branch: Renovate rebased prettier instead of merging the outdated state. The new commit no longer has a status; your success is attached to the old SHA. The express branches stay untouched (conflicted: only on conflict). A merge of PR #1 now provides that conflict, because both express PRs change the same line:

curl -s -o /dev/null -w '%{http_code}\n' -u "$ADMIN" -X POST "$API/pulls/1/merge" \
  --json '{"Do":"merge"}'
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/(express-5|prettier)" lauf.log > auszug.log
grep -E 'isConflicted\(\): true|needs rebasing|INFO: Branch' auszug.log | cut -c1-88
SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fprettier-3.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"success","context":"ci/test"}' | jq -r .status
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'automerged' auszug.log | cut -c1-88
curl -s -u "$ADMIN" "$API/pulls?state=all" \
  | jq -r '.[] | "#\(.number) \(.state) \(.head.ref) | \(.title)"'

Expected:

200
[prettier-3.x] DEBUG: Branch is behind base branch and needs rebasing
[prettier-3.x] INFO: Branch updated
[express-5.x] DEBUG: branch.isConflicted(): true
[express-5.x] DEBUG: Branch is not mergeable and needs rebasing
[express-5.x] INFO: Branch updated
success
[prettier-3.x] INFO: PR automerged
#1 merged renovate/express-4.x | Update dependency express to v4.22.3
#2 merged renovate/prettier-3.x | Update dependency prettier to v3.9.10
#3 open renovate/express-5.x | Update dependency express to v5

Every merge to main costs every automerge branch a rebase and a new CI run. With many automerge updates, they land one after another, not at the same time.

rebaseWhen Renovate rebases …
auto (default) like behind-base-branch with automerge, otherwise conflicted
behind-base-branch as soon as main has moved on (preset :rebaseStalePrs)
conflicted only on a merge conflict
automerging like behind-base-branch with automerge, otherwise never
never never (exception: rebase checkbox in the PR)

Tip: If you explicitly set rebaseWhen: "conflicted" with automergeType: "branch", Renovate cannot fast-forward an outdated branch. In the test, the result was WARN: Branch cannot automerge because it is behind base branch and rebaseWhen setting disallows rebasing - raising a PR instead.

Save your progress? Sign up for free

Drill 6: automergeSchedule and ignoreTests

automergeSchedule limits only the merge, not the creation of branches and PRs. In the test it was 4 p.m. UTC, and the window was 0:00 to 5:59 (without timezone, UTC applies). If you test at night, choose a different one.

jq '.packageRules[0].automergeSchedule = ["* 0-5 * * *"]' automerge-branch.json \
  > automerge-nachts.json
curl -s -o /dev/null -w '%{http_code}\n' -u "$ADMIN" -X DELETE "$API"
git -C ~/renovate-lab/shop-api push -q forgejo:shop/shop-api.git main
curl -s -u "$ADMIN" -X PATCH --json '{"has_actions":false}' "$API" | jq .has_actions
rm -rf shop-api
git clone -q forgejo:shop/shop-api.git
cp automerge-nachts.json shop-api/renovate.json
git -C shop-api add renovate.json
git -C shop-api commit -qm "Renovate-Konfiguration"
git -C shop-api push -q
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'INFO' auszug.log | cut -c1-88
SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fprettier-3.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"success","context":"ci/test"}' | jq -r .status
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'not scheduled|mergeStatus|off schedule' auszug.log | cut -c1-88

Expected:

[prettier-3.x] INFO: Branch created
success
[prettier-3.x] DEBUG: Package not scheduled
[prettier-3.x] DEBUG: mergeStatus=off schedule
[prettier-3.x] DEBUG: Branch cannot automerge now because automergeSchedule is off sched

Green, but outside the window: the branch waits. It is merged in the first run inside the window, so only if a run actually takes place then.

ignoreTests: true is the opposite: Renovate treats every branch as green. For the lab only!

jq '.packageRules[0].ignoreTests = true' automerge-branch.json > automerge-blind.json
curl -s -o /dev/null -w '%{http_code}\n' -u "$ADMIN" -X DELETE "$API"
git -C ~/renovate-lab/shop-api push -q forgejo:shop/shop-api.git main
curl -s -u "$ADMIN" -X PATCH --json '{"has_actions":false}' "$API" | jq .has_actions
rm -rf shop-api
git clone -q forgejo:shop/shop-api.git
cp automerge-blind.json shop-api/renovate.json
git -C shop-api add renovate.json
git -C shop-api commit -qm "Renovate-Konfiguration"
git -C shop-api push -q
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'INFO|Ignore tests' auszug.log | cut -c1-88
curl -s -u "$ADMIN" "$API/commits?sha=main&limit=2" \
  | jq -r '.[].commit.message | split("\n")[0]'

Expected:

[prettier-3.x] INFO: Branch created
[prettier-3.x] DEBUG: Ignore tests. Return green
[prettier-3.x] INFO: Branch automerged
2a91995 Update dependency prettier to v3.9.10
366f1d4 Renovate-Konfiguration

Created and merged in the same run, without any CI ever running. Normally Renovate checks freshly pushed branches only in the next run. ignoreTests overrides that.

Security: ignoreTests (preset :skipStatusChecks) means: a compromised package lands on main unchecked. Never in production.

Save your progress? Sign up for free

Drill 7: minimumReleaseAge and renovate/stability-days

You know minimumReleaseAge from Day 4. Renovate then sets its own check. Is that enough on its own for automerge?

jq '.packageRules[0].minimumReleaseAge = "3 days"' automerge-branch.json \
  > automerge-reif.json
curl -s -o /dev/null -w '%{http_code}\n' -u "$ADMIN" -X DELETE "$API"
git -C ~/renovate-lab/shop-api push -q forgejo:shop/shop-api.git main
curl -s -u "$ADMIN" -X PATCH --json '{"has_actions":false}' "$API" | jq .has_actions
rm -rf shop-api
git clone -q forgejo:shop/shop-api.git
cp automerge-reif.json shop-api/renovate.json
git -C shop-api add renovate.json
git -C shop-api commit -qm "Renovate-Konfiguration"
git -C shop-api push -q
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'INFO|stability' auszug.log | cut -c1-88
curl -s -u "$ADMIN" "$API/commits/renovate%2Fprettier-3.x/status" | jq -r .state
curl -s -u "$ADMIN" "$API/commits/renovate%2Fprettier-3.x/status" \
  | jq -r '.statuses[] | "\(.context) = \(.status)"'
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'internal|mergeStatus' auszug.log | cut -c1-88

Expected:

[prettier-3.x] INFO: Branch created
[prettier-3.x] DEBUG: Updating renovate/stability-days status check state to green
success
  renovate/stability-days = success
[prettier-3.x] DEBUG: Successful checks are all internal renovate/ checks, so returning 
[prettier-3.x] DEBUG: mergeStatus=no automerge
[prettier-3.x] DEBUG: Successful checks are all internal renovate/ checks, so returning 

The truncated line ends with "pending" branch status. Forgejo sees success, Renovate does not: if all green checks are Renovate’s own renovate/ checks, the branch counts as yellow (internalChecksAsSuccess: false). No real CI, no merge.

SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fprettier-3.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"success","context":"ci/test"}' | jq -r .status
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'INFO|mergeStatus' auszug.log | cut -c1-88
curl -s -u "$ADMIN" "$API/commits?sha=main&limit=1" \
  | jq -r '.[].commit.message | split("\n")[0]'

Expected:

success
[prettier-3.x] INFO: Branch automerged
[prettier-3.x] DEBUG: mergeStatus=automerged
30a0c02 Update dependency prettier to v3.9.9

Note the version: prettier 3.9.10 was only two days old at the time of the test, so Renovate chose 3.9.9. For you, that depends on the date.

Save your progress? Sign up for free

Drill 8: Branch protection as a second safety net

Renovate checks only checks that exist. If only the linter reports green and the test does not report at all, the branch is green. Branch protection with a required check catches that.

curl -s -o /dev/null -w '%{http_code}\n' -u "$ADMIN" -X DELETE "$API"
git -C ~/renovate-lab/shop-api push -q forgejo:shop/shop-api.git main
curl -s -u "$ADMIN" -X PATCH --json '{"has_actions":false}' "$API" | jq .has_actions
rm -rf shop-api
git clone -q forgejo:shop/shop-api.git
cp automerge-renovate.json shop-api/renovate.json
git -C shop-api add renovate.json
git -C shop-api commit -qm "Renovate-Konfiguration"
git -C shop-api push -q
curl -s -u "$ADMIN" -X POST "$API/branch_protections" --json '{"rule_name": "main",
  "enable_status_check": true, "status_check_contexts": ["ci/test"]}' \
  | jq -c '{rule_name, enable_push, status_check_contexts}'
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'INFO' auszug.log | cut -c1-88
SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fprettier-3.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"success","context":"ci/lint"}' | jq -r .status
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'Branch status green|Automerging|WARN|automerged' auszug.log | cut -c1-88
| sort -u
curl -s -u "$ADMIN" "$API/pulls" \
  | jq -r '.[] | "#\(.number) \(.state) \(.head.ref) | \(.title)"' | grep prettier

Expected:

{"rule_name":"main","enable_push":false,"status_check_contexts":["ci/test"]}
[prettier-3.x] INFO: Branch created
[prettier-3.x] INFO: PR created
success
[prettier-3.x] DEBUG: Automerging #2 with strategy auto
[prettier-3.x] DEBUG: Branch status green
[prettier-3.x] WARN: Merging of PR failed
#2 open renovate/prettier-3.x | Update dependency prettier to v3.9.10

Renovate considered the branch green and attempted the merge. Forgejo rejected it with HTTP 405 because ci/test is missing. Only the required check opens the door:

SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fprettier-3.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"success","context":"ci/test"}' | jq -r .status
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/prettier" lauf.log > auszug.log
grep -E 'automerged' auszug.log | cut -c1-88

Expected:

success
[prettier-3.x] INFO: PR automerged

Warning: For automergeType: "branch" this only helps halfway. Without push rights to main, the push fails (pre-receive hook declined), and Renovate falls back to a PR. If the bot is on the push whitelist, it pushes directly, and Forgejo does not check the required checks: in the test, an update with only ci/lint landed on main.

Save your progress? Sign up for free

Checkpoint

State after Drill 8: Actions off, automerge rule without platformAutomerge:

cd ~/renovate-lab/tag05
curl -s -u "$ADMIN" "$API" | jq .has_actions
curl -s -u "$ADMIN" "$API/raw/renovate.json" | jq '.packageRules[0].automerge'
curl -s -u "$ADMIN" "$API/raw/renovate.json" | jq .platformAutomerge

Expected:

false
true
false

Branch protection requires ci/test, prettier is merged and newer on main:

curl -s -u "$ADMIN" "$API/branch_protections/main" | jq -c .status_check_contexts
curl -s -u "$ADMIN" "$API/pulls?state=closed" | jq -r '.[] | "\(.merged) \(.head.ref)"'
curl -s -u "$ADMIN" "$API/raw/package.json" | jq -r .devDependencies.prettier

Expected:

R05_KP

Challenge

All patch and minor updates, including production dependencies, should run via branch automerge without PR noise, but only with a green ci/test. Show that a red test creates a PR instead of a merge, and that the PR is still merged automatically after a green test.

Hint: Let the ci/test statuses for express and prettier turn out differently and watch what the merge of prettier does to the express branch.

Solution

cd ~/renovate-lab/tag05
cat > challenge.json <<'EOF'
{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "extends": ["config:recommended"],
  "enabledManagers": ["npm"],
  "prHourlyLimit": 0,
  "platformAutomerge": false,
  "packageRules": [
    {
      "description": "Alle patch/minor-Updates: Branch-Automerge nur bei grünem CI",
      "matchUpdateTypes": ["patch", "minor"],
      "automerge": true,
      "automergeType": "branch"
    }
  ]
}
EOF
curl -s -o /dev/null -w '%{http_code}\n' -u "$ADMIN" -X DELETE "$API"
git -C ~/renovate-lab/shop-api push -q forgejo:shop/shop-api.git main
curl -s -u "$ADMIN" -X PATCH --json '{"has_actions":false}' "$API" | jq .has_actions
rm -rf shop-api
git clone -q forgejo:shop/shop-api.git
cp challenge.json shop-api/renovate.json
git -C shop-api add renovate.json
git -C shop-api commit -qm "Renovate-Konfiguration"
git -C shop-api push -q
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E 'INFO' lauf.log | cut -c1-88
curl -s -u "$ADMIN" "$API/pulls" \
  | jq -r '.[] | "#\(.number) \(.state) \(.head.ref) | \(.title)"'
SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fexpress-4.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"failure","context":"ci/test"}' | jq -r .status
SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fprettier-3.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"success","context":"ci/test"}' | jq -r .status
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E 'INFO|mergeStatus' lauf.log | cut -c1-88
curl -s -u "$ADMIN" "$API/pulls" \
  | jq -r '.[] | "#\(.number) \(.state) \(.head.ref) | \(.title)"'
curl -s -u "$ADMIN" "$API/issues/3/comments" | jq -r '.[].body' | fold -s -w 88

Expected:

[express-4.x] INFO: Branch created
[prettier-3.x] INFO: Branch created
[express-5.x] INFO: Branch created
[express-5.x] INFO: PR created
#1 open renovate/express-5.x | Update dependency express to v5
failure
success
[express-4.x] DEBUG: mergeStatus=branch status error
[express-4.x] DEBUG: Branch automerge not possible, mergeStatus:branch status error
[express-4.x] INFO: PR created
[express-4.x] INFO: Comment added
[prettier-3.x] INFO: Branch automerged
[prettier-3.x] DEBUG: mergeStatus=automerged
[express-4.x] INFO: Branch updated
[express-5.x] DEBUG: mergeStatus=no automerge
#1 open renovate/express-5.x | Update dependency express to v5
#3 open renovate/express-4.x | Update dependency express to v4.22.3
### Branch automerge failure

This PR was configured for branch automerge. However, this is not possible, so it has 
been raised as a PR instead.
___
 * Branch has one or more failed status checks

Red leads to PR #3 with a comment. prettier went directly to main, after which Renovate rebased the express branch in the same run (Branch updated), and the red status is gone. The CI runs again and is green this time:

curl -s -u "$ADMIN" "$API/commits/renovate%2Fexpress-4.x/status" | jq -r .state
curl -s -u "$ADMIN" "$API/commits/renovate%2Fexpress-4.x/status" \
  | jq -r '.statuses[] | "\(.context) = \(.status)"'
SHA=$(curl -s -u "$ADMIN" "$API/branches/renovate%2Fexpress-4.x" | jq -r .commit.id)
curl -s -u "$ADMIN" "$API/statuses/$SHA" \
  --json '{"state":"success","context":"ci/test"}' | jq -r .status
LOG_LEVEL=debug renovate shop/shop-api > lauf.log 2>&1
grep -E "branch=renovate/express-4" lauf.log > auszug.log
grep -E 'mergeStatus|INFO' auszug.log | cut -c1-88
curl -s -u "$ADMIN" "$API/pulls?state=all" \
  | jq -r '.[] | "#\(.number) \(.state) \(.head.ref) | \(.title)"'
curl -s -u "$ADMIN" "$API/commits?sha=main&limit=3" \
  | jq -r '.[].commit.message | split("\n")[0]'

Expected:


success
[express-4.x] DEBUG: mergeStatus=automerge aborted - PR exists
[express-4.x] DEBUG: Branch automerge not possible, mergeStatus:automerge aborted - PR e
[express-4.x] INFO: PR automerged
#1 open renovate/express-5.x | Update dependency express to v5
#3 merged renovate/express-4.x | Update dependency express to v4.22.3
5a6557d Merge pull request 'Update dependency express to v4.22.3' (#3) from reno
4dfc967 Update dependency express to v4.22.3
8c5af5c Update dependency prettier to v3.9.10

Once a PR exists, the branch route is closed (PR exists), and Renovate merges the PR. With the default platformAutomerge: true, Forgejo would have scheduled the fallback PR for merge as soon as it was created and merged it on the first green status without a run. The test showed that as well. express 5 is a major and stays a regular PR.

Save your progress? Sign up for free

Enterprise Note

  • Automerge only with a CI that runs on every Renovate branch and reports a status. Plus branch protection with required checks, otherwise any green check is enough.
  • automergeType: "branch" needs push rights to main and bypasses required checks and reviews in the process. Only for low-risk updates (lockfile, devDependencies); there is no PR as an audit trail, only the commit.
  • Without platformAutomerge, the run interval determines the latency, and every merge to main forces a rebase and new CI. Plan the run cadence and automergeSchedule around the CI capacity (Day 10).
  • ignoreTests does not belong in any production config. Combine automerge with minimumReleaseAge (Day 4, Day 12) so that fresh, possibly compromised releases do not land immediately.
  • GitHub and GitLab: there, platformAutomerge uses auto-merge or “Merge when pipeline succeeds”. On GitHub, “Allow auto-merge” must be enabled in the repo; merge queues require automergeType: "pr" (shortened, may differ depending on version).