Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub workflow is not triggered after pushing tags?

I have a GitHub workflow as below.

name: Releaser

on:
  push:
    tags:
      - 'v*.*.*'

This workflow will be triggered when I manually push a new tag like v1.1.1-rc1. It works fine.

Now, I want to have another workflow to replace the "manually push".

name: sync-tags

on:
  workflow_dispatch:
  push:
    paths:
      - TAGS

jobs:
  steps:
    - name: foo-example
      uses: foo-example 

This workflow will be triggered when there's a change made in the TAGS directory. The jobs will create a new tag like v1.1.1-rc1. It works fine as well. But, after the v1.1.1-rc1 is created by the sync-tags, the Releaser is not triggered.

I was wondering why the Releaser can be triggered by manually pushing tags but can't be triggered by tagging from other workflows?

like image 703
pellucid Avatar asked Jul 30 '26 22:07

pellucid


1 Answers

I am having this same problem. It turns out this is intentional behavior from GitHub Actions.

… if a workflow run pushes code using the repository's GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.

Explicitly invoking the release workflow works! (Note: this needs GITHUB_TOKEN in the environment, which I happen to do for the entire workflow.)

      - name: New tag & launch release process
        run: |
          echo "Tagging $new_tag"
          git tag $new_tag
          git push --tags
          # Explicitly run our release workflow for this new tag
          gh workflow run release.yml --ref $new_tag

My release workflow needed to be enhanced to allow manual runs. The workflow_dispatch: line in the on: section.

on:
  push:
    tags:
      - 'v*.*.*'
  workflow_dispatch:

To make sure we're building a release on a tag, I added if: github.ref_type == 'tag' to each job within the release workflow.

like image 180
Bruce Adams Avatar answered Aug 03 '26 09:08

Bruce Adams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!