From e3fee0902bf3e8000b998a8e2f0d60cafdf2136a Mon Sep 17 00:00:00 2001 From: Suisuroru Date: Thu, 23 Jan 2025 14:18:16 +0800 Subject: [PATCH] ci: optimizing the tag presence checking process --- .github/workflows/auto_build_jar.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/auto_build_jar.yml b/.github/workflows/auto_build_jar.yml index 0dfc8e2..c788671 100644 --- a/.github/workflows/auto_build_jar.yml +++ b/.github/workflows/auto_build_jar.yml @@ -39,10 +39,9 @@ jobs: - name: Check if tag exists id: check_tag run: | - GITHUB_REPOSITORY="${{ github.repository }}" - OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1) - REPO=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2) - TAG_EXISTS=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" https://api.github.com/repos/$OWNER/$REPO/git/refs/tags/${{ env.VERSION }} | jq -e '.ref' | wc -l) + OWNER=$(echo "${{ github.repository }}" | cut -d'/' -f1) + REPO=$(echo "${{ github.repository }}" | cut -d'/' -f2) + TAG_EXISTS=$(gh api -H "api.github.com" /repos/$OWNER/$REPO/git/refs/tags/${{ env.VERSION }} --jq '.ref' | wc -l) if [ "$TAG_EXISTS" -eq 1 ]; then echo "Tag exists" echo "SKIP_BUILD=true" >> $GITHUB_ENV @@ -50,6 +49,8 @@ jobs: echo "Tag does not exist" echo "SKIP_BUILD=false" >> $GITHUB_ENV fi + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} - name: Update version in plugin.yml if: env.SKIP_BUILD == 'false'