Conditional block run based on commit message

I’d like to run a block only if a certain word is included in the commit message.
Any suggestion on how to achieve that? I didn’t find a solution on the documentation.

@coorasse I’m afraid that you can’t do natively using semaphore dsl, however since you can run any script, you can check the commit or PR using github and skip the job, when it mets your conditions.
I did a similar thing and wanted to skip the job if the PR is labelled with a certain labels: Skip semaphore job on certain github PR labels · GitHub

Thanks! This is interesting

I didn’t exactly understand why but I never get a value for SEMAPHORE_GIT_PR_NUMBER env variable

Thanks for bringing this use case to our attention @coorasse!

@knapo is right, currently, this can’t be achieved natively but we have an internal feature request for this scenario so I’ve added your vote as well.

In the meantime, you can use a workaround based on the above post to run a job only when the commit message contains a certain word:

  - checkout
  - |
    if git log -1 --pretty=%B | grep -q '<word>'; then
      echo 'Run the job'

I understand how this not might be ideal, but it should definitely help.
Regarding SEMAPHORE_GIT_PR_NUMBER, this environment variable is only available when building pull requests so this is most likely why it’s not present in your job environment.