Conditional GitHub action based on commit message

mliakos

Emmanouil Liakos

Posted on November 1, 2021

Conditional GitHub action based on commit message

It's really annoying having a certain build/deployment GitHub action run on every push.

You can use this to run it based on the commit message's content:

name: Publish

on:
  push:
    branches:
      - master

jobs:
  publish:
    if: "contains(github.event.head_commit.message, '[build]')"
Enter fullscreen mode Exit fullscreen mode

Feel free to change the '[build]' part with whatever string you want.

You can also put a ! at the beginning to invert the logic (Run the action on commit messages that DON'T contain a certain string)

💖 💪 🙅 🚩
mliakos
Emmanouil Liakos

Posted on November 1, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related