首页 > 解决方案 > GitHub Action - 错误未定义:在参考或输入中找不到标签

问题描述

我正在尝试创建一个 GitHub 操作,该操作将检测某个分支何时发生更改,然后构建一个版本。我遇到的问题是在我的 yml 文件中我使用了这一行:

ncipollo/release-action@v1。这需要一个可用的标签,否则它将失败。我已经创建并推送了一个标签,但是当我运行该操作时出现此错误

Error undefined: No tag found in ref or input!

这是我的 yml 文件:

# Creates a release whenever a new change gets pushed onto the dev branch
# https://github.com/ncipollo/release-action

name: Dev-Build
on:  
  push:
    branches:
      - dev
jobs:
  build:
    name: setup environment 
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [12.x]

    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - 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      
        run: |
          npm i
          npm run build:ci  
      - name: Create Release
        uses: ncipollo/release-action@v1
        with:
          token: ${{ secrets.TOKEN }}

标签: angulargithubcontinuous-integrationgithub-actions

解决方案


默认情况下,标签不会使用checkout 操作从远程拉取:

对于触发工作流的 ref/SHA,默认情况下只获取一个提交。设置fetch-depth: 0为获取所有分支和标签的所有历史记录。

请参阅文档如何获取所有标签和分支的所有历史记录:

steps:
 - uses: actions/checkout@v2
   with:
     fetch-depth: 0

推荐阅读