I have notices a weird but reproducible misbehavior with the automerge functionality. I have a couple of repositories that I need to orchestrate for a combined release process (aka poly repo) with a script:
exit 0
Repository settings: default, merge commit, no status checks or any branch protection (tested with many configurations).
With that workflow, the automerge feature gets stuck after the first repository almost always. To recover from this, I can simply add a success to that particular commit (via API). Alternatively, sleep 30 && exit 0
as workflow action resolves this issue too.
After diving into the code I suspect that there might an issue with the notification of commit statuses: the pull request might still check if it is mergeable and thus the automerge is not triggered.
This is also reproducible with a single repository and creating many branches + PRs + auto merge requests with a script. Roughly 50% of automergeable PRs get stuck with this:
Create a sample repository, e.g. I've cloned gitea/helm-gitea and used this repository with the script below.
env GITEA_HOST=git.example.com OWNER=My_User REPOSITORY=test-repo USERNAME=My_User PASSWORD=an_application_token ./reproduce-automerge-stuck.sh
#!/bin/bash # filename: reproduce-automerge-stuck.sh set -eu -o pipefail GITEA_HOST="${GITEA_HOST:-demo.gitea.com}" USERNAME="${USERNAME:-}" PASSWORD="${PASSWORD:-}" OWNER="${OWNER:-posativ}" REPOSITORY="${REPOSITORY:-automerge-issue}" if [[ -z "$USERNAME" || -z "$PASSWORD" ]]; then echo "Please set USERNAME and PASSWORD environment variables." exit 1 fi automerge() { TEST_BRANCH="test-branch-$(date +%s)" TEMP_DIR=$(mktemp -d) trap 'rm -rf "$TEMP_DIR"' EXIT # clone + config git clone --depth 1 "https://${USERNAME}:${PASSWORD}@${GITEA_HOST}/${OWNER}/${REPOSITORY}" "$TEMP_DIR/repo" cd "$TEMP_DIR/repo" git config user.name "foo" git config user.email "bar@example.com" # Create a new branch and commit changes git checkout -b "$TEST_BRANCH" echo "$(date +%s)" > "$TEST_BRANCH.txt" git add "$TEST_BRANCH.txt" git commit -m "Add test file" sha=$(git rev-parse HEAD) git push origin "$TEST_BRANCH" # set commit status to pending curl -vX POST -H "Content-Type: application/json" \ -u "$USERNAME:$PASSWORD" \ -d '{"context": "foo", "description": "bar", "state": "pending", "target_url": "https://example.com"}' \ "https://${GITEA_HOST}/api/v1/repos/${OWNER}/${REPOSITORY}/statuses/${sha}" # CI or something sleep 1 # set commit status to success curl -vX POST -H "Content-Type: application/json" \ -u "$USERNAME:$PASSWORD" \ -d '{"context": "foo", "description": "bar", "state": "success", "target_url": "https://example.com"}' \ "https://${GITEA_HOST}/api/v1/repos/${OWNER}/${REPOSITORY}/statuses/${sha}" # create pr index=$(curl -vX POST -H "Content-Type: application/json" \ -u "$USERNAME:$PASSWORD" \ -d "{\"head\": \"$TEST_BRANCH\", \"base\": \"main\", \"title\": \"Test PR\", \"body\": \"This is a test PR.\"}" \ "https://${GITEA_HOST}/api/v1/repos/${OWNER}/${REPOSITORY}/pulls" | jq -r '.number') # create auto merge curl -vX POST -H "Content-Type: application/json" \ -u "$USERNAME:$PASSWORD" \ -d '{"do": "merge", "merge_when_checks_succeed": true}' \ "https://${GITEA_HOST}/api/v1/repos/${OWNER}/${REPOSITORY}/pulls/${index}/merge" } automergeGitea Version
1.24
Can you reproduce the bug on the Gitea demo site?No
Log GistNo response
Screenshots Git Version1.24.2
Operating SystemNo response
How are you running Gitea?Official Gitea Helm Chart with Kubernetes + Valkey.
DatabasePostgreSQL
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4