[英]Github action skipping release file
我拥有一个 npm 包,并决定创建 Github 操作来有效地自动化流程。
main.yml
- 处理节点 CI。 在每次推送到主分支时,该操作将安装依赖项并通过多个操作系统进行构建。release.yml
- 需要向 npm 和 Github 发布新版本。 它会在每个以“v”开头的提交标签上触发(例如,“v0.1.4”)。 但是,在使用 commit 标签推送到 git 时会跳过release.yml
操作。
如何触发release.yml
文件? 但是,仍然等待main.yml
完成整个工作流程?
我会很感激你的帮助。
main.yml
动作:
name: Node Continous Integration
on:
push:
branches: [master]
jobs:
build:
name: Build on Node ${{ matrix.node }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['10.x', '12.x', '14.x']
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1
- name: Build
run: npm run build
release.yml
动作:
# Name of the workflow
name: Release new version
# Run on every commit tag which begins with "v" (e.g., "v0.1.4")
on:
push:
tags:
- "v*"
jobs:
# Automatically publish a NPM release
npm-publish:
name: NPM Release
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1
- name: Publish
run: npm publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# Automatically create a GitHub Release, with release details specified (the relevant commits)
github-release:
name: Github Release
needs: [npm-publish]
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
steps:
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
问题在于您在工作中的 if 条件。 if: ${{ github.ref == 'refs/heads/master' }}
在标签推送的情况下, github.ref
将类似于refs/tags/v.2.2.2
因为 if 条件与作业不匹配被跳过。
我在这里运行了一个示例作业来验证它。 关联
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.