title: How can I cancel a GitHub Actions workflow if the commit has no tag
body: <p>I have npm publish github actions, I want to run this action if my commit has tag, otherwise I don't want to run my action because of that if I do not add any tag my commit then action is run and failed because it try to publish already publish npm package with same tag. For example with my last commit I have tag <code>1.2.3</code> and my npm package was publish with <code>1.2.3</code> version. When I add new commit to my branch without any tag actions try to publish my package with <code>1.2.3</code> version tag so it failed. Here my actions code below, is there any solution for it.</p>
  <p>Thanks for advive.</p>
  <pre><code>name: NPM Publish
  
  on:
    push:
      branches:
      - master
      tags: 
      - v*
  
  jobs:
    build:
      name: Build  &amp; Publish 
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v1
        - uses: actions/setup-node@v2.4.0
          with:
            node-version: 12
            registry-url: https://registry.npmjs.org/      
        - run: npm install
        - run: npm publish --access public
          env:
            NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
  </code></pre>
  <p>I need something like that on yml file</p>
  <p><code>if(git_commit has tag) continue job else stop job;</code></p>
  <p><strong>EDITTED VERSION</strong></p>
  <p>I edit my yml file base on <a href="https://stackoverflow.com/users/26396/enrico-campidoglio">@Enrico Campidoglio</a> suggestion but still is does not work. I made two commit first one without tag and it canceled the action but second one has tag it still canceled action. Is there any new suggestion or solution ?</p>
  <pre><code>name: NPM Publish
  
  on:
    push:
      branches:
      - master
  
  jobs:
    build:
      name: Build  &amp; Publish 
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v1
        - uses: actions/setup-node@v2.4.0
          with:
            node-version: 12
            registry-url: https://registry.npmjs.org/
        - run: echo &quot;GIT_COMMIT=`echo $(git rev-parse --short HEAD)`&quot; &gt;&gt; $GITHUB_ENV
        - run: echo &quot;GIT_TAG=`echo $(git describe --tags --exact-match ${{ env.GIT_COMMIT }} || :)`&quot; &gt;&gt; $GITHUB_ENV
        - run: echo ${{ env.GIT_TAG }} != v*
        - run: |
            if [[ ${{ env.GIT_TAG }} == v* ]] ; then
            echo &quot;Tag found...&quot;
            else
            echo &quot;No git tag found, action cancelled...&quot;
            exit 1
            fi
  
  
        - uses: andymckay/cancel-action@0.2
          if: ${{ env.GIT_TAG }} != v*
            
        - run: npm install
        - run: npm publish --access public
          env:
            NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
  </code></pre>
  <p>there is action result I cannot figure out what is the problem,</p>
  <p><a href="https://i.stack.imgur.com/1JcBZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1JcBZ.png" alt="enter image description here" /></a></p>
  <p>here the lastest failed action: <a href="https://github.com/sametcelikbicak/enum2array/runs/3513521031?check_suite_focus=true" rel="nofollow noreferrer">https://github.com/sametcelikbicak/enum2array/runs/3513521031?check_suite_focus=true</a></p>