How to best deal with long conditional expressions in GitHub Actions Workflow?
I have a workflow that I want to run in 2 cases:
- when a pull request is closed
- when a comment containing a specific string is created on a pull request
This leads to a workflow definition with a long if expression:
on:
pull_request:
types: [ closed ]
issue_comment:
types: [ created ]
jobs:
do:
if: ${{ github.event_name == 'pull_request' || (github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, 'specific string')) }}
steps:
...
A solution I see is to split the workflow in 2 definitions, but I'd like to avoid this due to DRY.
Ideas I searched for, but did not find working solutions for:
- define the expression on multiple lines
- split the if in multiple if expressions