I have the GitHub action that should only be ran when the commit message contains 'test_api'. However, I do want it to be a required check for the PR to be able to get merged. For some reason this is not picked up, and it does not make any sense to me.
jobs:
api-tests:
if: contains(github.event.commits[0].message, '[test_api]')
runs-on: ubuntu-latest
...
CodePudding user response:
It says that tests were skipped - that means this is not true:
if: contains(github.event.commits[0].message, '[test_api]')
Unless you have more actions in the workflow.
CodePudding user response:
I would force a failure if the condition isn't true.
jobs:
api-tests:
if: contains(github.event.commits[0].message, '[test_api]')
runs-on: ubuntu-latest
steps:
...
not-api-tests:
if: "!contains(github.event.commits[0].message, '[test_api]')"
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Fail the job
run: exit 1
Note: This should work on all 3 platforms (ubuntu, macos, windows).
I tested it here (committing with [test_api]) and here (forcing the error with another commit message). The workflow implementation can be found here.