From 82a6380fc4529baf7e7d59ee8af9e6ef469feb22 Mon Sep 17 00:00:00 2001 From: Giovanni Bassi Date: Mon, 25 Sep 2023 20:08:28 -0300 Subject: [PATCH] Fix tag gh action script 404 status throws errors, we are catching that. --- .github/workflows/tag.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 2fcbf77..2e95037 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -24,14 +24,21 @@ jobs: name: Create tag with: script: | - const tag = await github.rest.git.getRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: 'tags/${{ steps.version.outputs.VERSION }}' - }); - if (tag != null && tag.status == 200) { - console.error('Tag ${{ steps.version.outputs.VERSION }} already exists.'); - return; + try { + const tag = await github.rest.git.getRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'tags/${{ steps.version.outputs.VERSION }}' + }); + if (tag != null && tag.status == 200) { + console.log('Tag ${{ steps.version.outputs.VERSION }} already exists.'); + return; + } + } catch (error) { + if (error.status !== 404) { + console.error('Error when trying to get tag ${{ steps.version.outputs.VERSION }}.'); + return; + } } const main = await github.rest.git.getRef({ owner: context.repo.owner,