Skip to content

Commit 82a6380

Browse files
committed
Fix tag gh action script
404 status throws errors, we are catching that.
1 parent ce13f36 commit 82a6380

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

.github/workflows/tag.yml

+15-8
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,21 @@ jobs:
2424
name: Create tag
2525
with:
2626
script: |
27-
const tag = await github.rest.git.getRef({
28-
owner: context.repo.owner,
29-
repo: context.repo.repo,
30-
ref: 'tags/${{ steps.version.outputs.VERSION }}'
31-
});
32-
if (tag != null && tag.status == 200) {
33-
console.error('Tag ${{ steps.version.outputs.VERSION }} already exists.');
34-
return;
27+
try {
28+
const tag = await github.rest.git.getRef({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
ref: 'tags/${{ steps.version.outputs.VERSION }}'
32+
});
33+
if (tag != null && tag.status == 200) {
34+
console.log('Tag ${{ steps.version.outputs.VERSION }} already exists.');
35+
return;
36+
}
37+
} catch (error) {
38+
if (error.status !== 404) {
39+
console.error('Error when trying to get tag ${{ steps.version.outputs.VERSION }}.');
40+
return;
41+
}
3542
}
3643
const main = await github.rest.git.getRef({
3744
owner: context.repo.owner,

0 commit comments

Comments
 (0)