catalyst / catalyst-moodle-workflows

5 stars 10 forks source link

issue #116: fix fetch-depth ternary #117

Closed djarran closed 5 months ago

djarran commented 5 months ago

Description: There is an issue with the 'ternary' operators in GitHub Actions outlined in this discussion:

There seems to be a way because there is "ternary like" operator in Github actions https://docs.github.com/en/actions/learn-github-actions/expressions#example . One thing to watch for is that "true value" (one after &&) need to be "truthy" to work as expected

${{ github.event_name == 'release' && github.ref || inputs.release_ref }}

This article also describes the same issue as above and outlines the solution that is used in this PR.


Solution:

We flip the condition so that the value to use if true (second operand) is truthy

fetch-depth: ${{ !((contains(github.event_name, 'push') && steps.check-branch.outputs.publishable == 'true')) && 2 || 0 }}