diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml index fc62135..fa036b7 100644 --- a/.github/workflows/auto-tag.yml +++ b/.github/workflows/auto-tag.yml @@ -25,8 +25,9 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + ref: ${{ github.event.workflow_run.head_sha }} persist-credentials: false - + - name: Check for skip keyword id: check_skip run: | @@ -54,7 +55,14 @@ jobs: PAT: ${{ secrets.PAT_TOKEN }} TAG: ${{ steps.version.outputs.new_tag }} run: | + set -e git config user.name "GitHub Action" git config user.email "action@github.com" + + if git show-ref --tags --verify --quiet "refs/tags/$TAG"; then + echo "Tag $TAG already exists, skipping" + exit 0 + fi + git tag -a "$TAG" -m "Auto tag $TAG" - git push "https://x-access-token:${PAT}@github.com/${{ github.repository }}.git" "$TAG" + git push "https://x-access-token:${PAT}@github.com/${{ github.repository }}.git" "$TAG" \ No newline at end of file