GitHub Actions tag filter with branch filter

余生长醉 提交于 2020-07-08 11:51:53

问题


GitHub actions allow the use of branch and tag filters, but they don't seem to work together.

For example, this workflow runs on pushes to master or pushes with a tag.

name: npm Publish

on:
  push:
    branches:
      - master
    tags:
      - v*

I want to setup a publishing workflow that runs on tagged pushes to master, not just one or the other. How can this be done?


回答1:


One solution is to use on: release instead of on: push. This will trigger the workflow to execute when a release is published via the GitHub UI. When you publish a release on GitHub it tags the master branch with the version of the release that you specify. Each execution of the workflow is therefore guaranteed to be a tagged commit on the master branch.

name: npm Publish

on: release


来源:https://stackoverflow.com/questions/57963374/github-actions-tag-filter-with-branch-filter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!