On trigger two conditions #25763
-
Hello, Is it possible to use two on trigger conditions, such as: on: It looks like it passes the parsing, but does it behave as OR or AND condition? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 1 reply
-
Any way to run GitHub action combining In english words: |
Beta Was this translation helpful? Give feedback.
-
Yes, I meant the part of which event(s) will trigger workflows. Path and branch filters within each event are AND, as far as I know. 🙂 |
Beta Was this translation helpful? Give feedback.
-
So, your question isn’t unreasonable, and afaict the documentation doesn’t spell this out:
Workflow syntax for GitHub Actions - GitHub DocsA workflow is a configurable automated process made up of one or more jobs. You must create a YAML file to define your workflow configuration. So, if I were you, I’d file a bug asking them to clarify. But note, there are two unrelated things you’re asking about, and that isn’t helpful.
Build software better, togetherGitHub is where people build software. More than 73 million people use GitHub to discover, fork, and contribute to over 200 million projects. |
Beta Was this translation helpful? Give feedback.
-
Sorry for being unclear. The question was about how two conditions per event behave in GitHub Actions, and you basically answered it. |
Beta Was this translation helpful? Give feedback.
-
The code is clearer now, but unfortunately your question isn’t. The events and their filters would still be handled completely separately. |
Beta Was this translation helpful? Give feedback.
-
Those can be related events. For example I want to trigger pull_request or merge only if given path conditions are met. If pull_request and files changed in src/.c or merge and files change in src/.c. Sorry, the original message have the code block messed up:
|
Beta Was this translation helpful? Give feedback.
-
Those are very unrelated events. All events effectively happen in parallel. My action has extra code that effectively ends a push event if it detects there’s an open pull request. Workflow:check-spelling/spell-check-this/blob/ad8754db6e49d737690f5005c8f332f069e3fe8d/.github/workflows/spelling.ymlname: Spell checking
on:
push:
branches: ["**"]
tags-ignore: ["**"]
pull_request_target:
issue_comment:
types: [created]
jobs:
spelling:
name: Spell checking
permissions:
contents: read
pull-requests: read
outputs:
internal_state_directory: ${{ steps.spelling.outputs.internal_state_directory }}
runs-on: ubuntu-latest
if: "contains(github.event_name, 'pull_request') || github.event_name == 'push'"
concurrency:
... Action definition: https://github.com/check-spelling/check-spelling/blob/8919d434aab1251e80d394a2a83a00668f4e106b/action.yml#L122-L123 suppress_push_for_open_pull_request:
description: "If set, do not do work in response to `push` if there is an open `pull` request to the repository for the branch (this assumes there's a `pull_request_target` event configured)." Code: check-spelling/check-spelling/blob/8919d434aab1251e80d394a2a83a00668f4e106b/check-pull-requests.sh#!/bin/bash
. "$spellchecker/common.sh"
if [ $(uname) = "Linux" ]; then
date_to_epoch() {
date -u -d "$1" +'%s'
}
else
date_to_epoch() {
date -u -j -f '%Y-%m-%dT%H:%M:%SZ' "$1" +'%s'
}
fi
timeframe=${timeframe:-60}
time_limit=$(( $timeframe * 60 ))
strip_quotes() {
tr '"' ' '
}
begin_group 'Retrieving open pull requests'
pulls=$temp/pulls.json
... |
Beta Was this translation helpful? Give feedback.
-
Neither. 😉 Either of the conditions will trigger the workflow separately, so kind of similar to OR, but you’ll get multiple runs if multiple events occur. |
Beta Was this translation helpful? Give feedback.
Neither. 😉
Either of the conditions will trigger the workflow separately, so kind of similar to OR, but you’ll get multiple runs if multiple events occur.