From 7792e29065b94b9246ac70686c9cab08cb624ce5 Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Mon, 26 May 2025 16:44:48 +0300 Subject: [PATCH 1/2] Detail errors for workflows Signed-off-by: Timofei Larkin --- .github/workflows/pull-requests-release.yaml | 32 +++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pull-requests-release.yaml b/.github/workflows/pull-requests-release.yaml index 49fc63c6..1e82175c 100644 --- a/.github/workflows/pull-requests-release.yaml +++ b/.github/workflows/pull-requests-release.yaml @@ -96,34 +96,36 @@ jobs: repo: context.repo.repo, ref: `tags/${tag}` }); + const commitSha = ref.data.object.sha; try { - // Check if branch exists await github.rest.repos.getBranch({ owner: context.repo.owner, - repo: context.repo.repo, + repo: context.repo.repo, branch }); - - // Force update existing branch to the tag commit + await github.rest.git.updateRef({ owner: context.repo.owner, - repo: context.repo.repo, - ref: `refs/heads/${branch}`, - sha: commitSha, + repo: context.repo.repo, + ref: `heads/${branch}`, + sha: commitSha, force: true }); console.log(`🔁 Force-updated '${branch}' to ${commitSha}`); } catch (err) { - // Branch doesn't exist, create it - await github.rest.git.createRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: `refs/heads/${branch}`, - sha: commitSha - }); - console.log(`✅ Created branch '${branch}' at ${commitSha}`); + if (err.status === 404) { + await github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: `refs/heads/${branch}`, + sha: commitSha + }); + console.log(`✅ Created branch '${branch}' at ${commitSha}`); + } else { + console.error('Unexpected error --', err); + } } # Get the latest published release From c267c7eb9afffb6482df8788e0dec1ab3f039d64 Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Tue, 27 May 2025 12:20:00 +0300 Subject: [PATCH 2/2] Update .github/workflows/pull-requests-release.yaml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Timofei Larkin --- .github/workflows/pull-requests-release.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-requests-release.yaml b/.github/workflows/pull-requests-release.yaml index 1e82175c..7f7c2fcd 100644 --- a/.github/workflows/pull-requests-release.yaml +++ b/.github/workflows/pull-requests-release.yaml @@ -125,8 +125,9 @@ jobs: console.log(`✅ Created branch '${branch}' at ${commitSha}`); } else { console.error('Unexpected error --', err); + core.setFailed(`Unexpected error creating/updating branch: ${err.message}`); + throw err; } - } # Get the latest published release - name: Get the latest published release