-
Select Topic AreaQuestion Body
I want to trigger the workflow on pushing changes to main branch and on only specific paths but, for pushing tag I want to ignore paths, is that possible ? I mean one possible solution that I can think of is, define two workflow files but, apart from that are there any other solutions? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 11 replies
-
@code-R it is possible to define multiple paths for the on:
push:
branches:
- main
paths:
- "common/**"
- "myservice/**"
if: "!startsWith(github.ref, 'refs/tags/')"
push:
tags:
- "*"
branches:
- main
if: "startsWith(github.ref, 'refs/tags/')" |
Beta Was this translation helpful? Give feedback.
-
@jge162 thank you, will give that a try, I thought in yaml redefining same key will have override effect (similar to dictionaries or map) |
Beta Was this translation helpful? Give feedback.
-
@jge162 I expected the action to be triggered when tagged in the form of name: My GitHub Action
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
branches:
- main
if: startsWith(github.ref, 'refs/tags/')
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run my command
run: |
echo "hello world"
echo "${{ github.ref }}" |
Beta Was this translation helpful? Give feedback.
@code-R it is possible to define multiple paths for the
push
event and exclude specific paths for certain conditions such as tags. here is an example pseudo code.