From dbc3fdea0a4b35f02c6039ea26beea210c6a2e1d Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Tue, 6 Oct 2026 10:36:13 +0000 Subject: [PATCH] ci: use git push to create release branch Replace the GitHub API ref creation with git push, which reuses the app-token credentials from checkout and avoids HTTP 422 errors from the refs endpoint. Assisted-by: AI Signed-off-by: Alice Frosi --- .github/workflows/release.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 502aa26..d6d31bf 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -98,13 +98,16 @@ jobs: GH_TOKEN: ${{ steps.app-token.outputs.token }} run: | BRANCH="release-${VERSION%.*}" - if gh api "repos/${GITHUB_REPOSITORY}/branches/${BRANCH}" >/dev/null 2>&1; then + SHA=$(git rev-parse HEAD) + if gh api "repos/${GITHUB_REPOSITORY}/git/refs" \ + -f "ref=refs/heads/${BRANCH}" \ + -f "sha=${SHA}" 2>/dev/null; then + echo "Created branch ${BRANCH}" + elif gh api "repos/${GITHUB_REPOSITORY}/git/ref/heads/${BRANCH}" >/dev/null 2>&1; then echo "Branch ${BRANCH} already exists, skipping" else - SHA=$(git rev-parse HEAD) - gh api "repos/${GITHUB_REPOSITORY}/git/refs" \ - -f "ref=refs/heads/${BRANCH}" \ - -f "sha=${SHA}" + echo "::error::Failed to create branch ${BRANCH}" + exit 1 fi - name: Set up Go