DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Emmanouil Liakos
Emmanouil Liakos

Posted on

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)

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.