Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub Actions tag filter with branch filter

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?

like image 577
Kyeotic Avatar asked Sep 16 '19 19:09

Kyeotic


1 Answers

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
like image 65
peterevans Avatar answered Oct 12 '22 03:10

peterevans