How to Trigger a Workflow on a Tag Push in GitHub Actions
A tags filter on the push event fires only when a matching tag is pushed, not on ordinary branch commits.
Set on.push.tags to a glob like v*.*.*. Omit branches so branch pushes never trigger it, and read the tag name from github.ref_name.
Steps
- Add
tags:underon.pushwith a version glob. - Leave out
branches:so only tag pushes fire the run. - Reference the tag with
github.ref_nameinside jobs.
Workflow
.github/workflows/release.yml
on:
push:
tags:
- 'v*.*.*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "Building release ${{ github.ref_name }}"Gotchas
- Pushing a lightweight tag and a branch in one push can fire multiple matching workflows.
- Tag globs are fnmatch, not regex, so
v[0-9]+will not work; usev*style patterns.
Related guides
How to Trigger a Workflow When a Release Is Published in GitHub ActionsRun a GitHub Actions workflow when a GitHub Release is published using on.release with the published type, id…
How to Trigger a Workflow on Push to Specific Branches in GitHub ActionsRun a GitHub Actions workflow only when commits are pushed to named branches using on.push.branches, so featu…