Skip to content

Commit fb94da8

Browse files
committed
updated github action to check for tag
1 parent b3bcd19 commit fb94da8

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

.github/workflows/build-deploy.yml

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,22 @@ on:
99
required: true
1010
default: 'v0.0.0'
1111
jobs:
12+
check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check if tag already exists
16+
id: check_tag_exists
17+
uses: mukunku/[email protected]
18+
with:
19+
tag: ${{ github.event.inputs.tag }}
20+
# Create job outputs
21+
- name: Create job outputs
22+
id: create_job_outputs
23+
run: |
24+
echo "tag_exists=${{ steps.check_tag_exists.outputs.exists }}" >> $GITHUB_OUTPUTS
1225
build:
26+
needs: check
27+
if: ${{ needs.check.outputs.tag_exists == 'false' }}
1328
runs-on: ubuntu-latest
1429
steps:
1530
- uses: actions/checkout@v2
@@ -49,29 +64,16 @@ jobs:
4964
path: ./
5065

5166
# Check if the tag already exists
52-
- name: Check if release exists
53-
id: check_release
54-
uses: actions/github-script@v5
67+
- name: Check if tag already exists
68+
id: check_tag_exists
69+
uses: mukunku/[email protected]
5570
with:
56-
github-token: ${{ secrets.GITHUB_TOKEN }}
57-
script: |
58-
const release = await github.repos.getReleaseByTag({
59-
owner: context.repo.owner,
60-
repo: context.repo.repo,
61-
tag: context.ref.replace('refs/tags/', '')
62-
}).catch(err => {
63-
if (err.status === 404) {
64-
return null;
65-
}
66-
throw err;
67-
});
68-
console.log('Release exists: ' + (release !== null));
69-
return release ? { exists: 'true' } : { exists: 'false' };
71+
tag: ${{ github.event.inputs.tag }}
7072

7173
# Upload the VSIX file to the Github release
7274
- name: Create Release
7375
id: create_release
74-
if: ${{ steps.check_release.outputs.exists == 'false' }}
76+
if: ${{ steps.check_tag_exists.outputs.exists == 'false' }}
7577
uses: actions/create-release@latest
7678
env:
7779
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -83,7 +85,7 @@ jobs:
8385
draft: false
8486
prerelease: false
8587
- name: Upload Release Asset
86-
if: ${{ steps.check_release.outputs.exists == 'false' }}
88+
if: ${{ steps.check_tag_exists.outputs.exists == 'false' }}
8789
uses: actions/upload-release-asset@v1
8890
env:
8991
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)