Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger Github Action only on new tags?

Is there a possibility to tigger a github action only if a new version (which comes with a new tag) is pushed? I don't want run them on every push into master, but I also want to avoid creating a release branch.

like image 798
mrvnklm Avatar asked May 19 '20 12:05

mrvnklm


People also ask

Can you manually trigger a GitHub action?

Earlier this week, GitHub announced a new feature which allows developers to trigger workflows manually from within the “Actions” tab.

How do I run jobs sequentially in GitHub Actions?

To run jobs sequentially, you can define dependencies on other jobs using the jobs. <job_id>. needs keyword. Each job runs in a runner environment specified by runs-on .

Can you schedule GitHub Actions?

You can configure your workflows to run when specific activity on GitHub happens, at a scheduled time, or when an event outside of GitHub occurs.


2 Answers

Use the following syntax:

on:   push:     # Pattern matched against refs/tags     tags:               - '*'           # Push events to every tag not containing / 

For hierarchical tags:

on:   push:     # Pattern matched against refs/tags     tags:               - '**'           # Push events to every tag including hierarchical tags like v1.0/beta 

https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestbranchestags

like image 149
riQQ Avatar answered Oct 10 '22 08:10

riQQ


I got it to work with

on:   push:     tags:       - '*' 

I found out that if the tag was previously created (locally) before the workflow was created, no matter how many times I deleted and re-pushed the tag, it would not trigger until I deleted the tag locally and recreated it. The action does not seem to work for tags created before the workflow.

like image 20
Gridcell Coder Avatar answered Oct 10 '22 08:10

Gridcell Coder