Error undefined: No tag found in ref or input!

Hi,

I am trying to create an action that will detect when a change has happened on a certain branch and then build a release. The problem I’m getting is that in my file I use this line:

ncipollo/release-action@v1 This requires a tag to be available otherwise it will fail. I have created and pushed a tag but when I run the action I get this error

Error undefined: No tag found in ref or input!

This is my yml file:

name: Manual workflow
on:  
  push:
    branches:
      - dev
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [12.x]

    steps:
      - uses: actions/checkout@v2.3.4

      - name: Cache node modules
        uses: actions/cache@v2.1.3
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-
      - name: Node ${{ matrix.node-version }}
        uses: actions/setup-node@v1.4.4
        with:
          node-version: ${{ matrix.node-version }}
      - name: npm install and     
        run: |
          npm i
          npm run-script build --prod  
      - name: Push Build to Releases
        uses: ncipollo/release-action@v1
        with:
          artifacts: "dist/angular-githubaction/*"
          token: ${{ secrets.TOKEN }}

Looks like the problem is that your workflow runs on branch push, not tag push, so github.ref doesn’t contain your tag.

Hmm, how would I get it to include my tags? As far as I’m aware you can set GitHub actions to perform when something is pushed to a certain branch.

I have added
- uses: actions/checkout@v2 with: fetch-depth: 0
this so that it will fetch everything but that hasn’t fixed my problem.

It’s not about the job, it’s about the workflow trigger. You currently have this:

That means the workflow will run if you push the dev branch, and github.ref will always be refs/heads/dev. The workflow will not run when you push a tag, so that action cannot automatically determine the tag you want to use.

According to the ncipollo/release-action README you have two options:

  • Run the workflow on tag pushes. This is the obvious one: If you push a tag, the release will be made using that tag. For example, to make a release on any tag:
on:  
  push:
    tags:
      - '*'
  • Specify the tag name when calling the action, by adding a tag keyword in the with section.

If you want to run on both tag and branch pushes and skip the release on non-tag pushes, you could use an if condition like

if: ${{ startsWith(github.ref, 'refs/tags/') }}

on the release step to run it only for tags.

1 Like

Thanks, I ended up just changing it to a trigger on tag

1 Like