From fd4c720a59272af3a8fd579ea9bc30b1b2614805 Mon Sep 17 00:00:00 2001 From: cuisongliu Date: Tue, 27 Jun 2023 14:34:56 +0800 Subject: [PATCH] feature(main): add issue comment (#46) Signed-off-by: cuisongliu --- .github/workflows/test-pr-comment.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-pr-comment.yml b/.github/workflows/test-pr-comment.yml index 2d48e24..c941476 100644 --- a/.github/workflows/test-pr-comment.yml +++ b/.github/workflows/test-pr-comment.yml @@ -22,7 +22,27 @@ jobs: return; } const milestone = pr.milestone.title; - const cherryPickCmd = `/cherry-pick ${milestone}-release`; + const ref = `heads/release-${milestone}`; + let branchExists; + try { + await github.rest.git.getRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: ref + }); + branchExists = true; + } catch (error) { + if (error.status === 404) { + console.log(`Branch ${ref} does not exist. Skipping...`); + branchExists = false; + } else { + throw error; // Rethrow if it's another error + } + } + if (!branchExists) { + return; + } + const cherryPickCmd = `/cherry-pick release-${milestone}`; console.log(`Adding comment: ${cherryPickCmd}`); await github.rest.issues.createComment({ owner: context.repo.owner,