From 569653551c331070a1508317c409e9094f520dfc Mon Sep 17 00:00:00 2001 From: Will Smith Date: Wed, 31 Jan 2024 14:20:17 -0800 Subject: [PATCH] Add error handling in case release branch doesn't exist yet (#7094) # Description Fix release issue: https://github.com/radius-project/radius/actions/runs/7732739510/job/21083323439 ## Type of change - This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Radius (issue link optional). Signed-off-by: willdavsmith Signed-off-by: Josh --- .github/workflows/release.yaml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 16d605ae6cb..7a7e1904088 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -170,17 +170,22 @@ jobs: with: result-encoding: string script: | - const { data } = await github.rest.repos.getBranch({ - owner: context.repo.owner, - repo: context.repo.repo, - branch: '${{ steps.get-version.outputs.release-branch-name }}', - }) + try { + const { data } = await github.rest.repos.getBranch({ + owner: context.repo.owner, + repo: context.repo.repo, + branch: '${{ steps.get-version.outputs.release-branch-name }}', + }) - if (data.name == '${{ steps.get-version.outputs.release-branch-name }}' && context.ref == 'refs/heads/main' && context.eventName == 'push') { - console.log("Release branch ${{ steps.get-version.outputs.release-branch-name }} already exists and this is a push to main.") - return 'true' - } else { - console.log("Release branch ${{ steps.get-version.outputs.release-branch-name }} does not exist or this is not a push to main.") + if (data && data.name == '${{ steps.get-version.outputs.release-branch-name }}' && context.ref == 'refs/heads/main' && context.eventName == 'push') { + console.log("Release branch ${{ steps.get-version.outputs.release-branch-name }} already exists and this is a push to main.") + return 'true' + } else { + console.log("This is not a push to main.") + return 'false' + } + } catch (error) { + console.log("Release branch ${{ steps.get-version.outputs.release-branch-name }} does not exist.") return 'false' } - name: Generate release summary