DEV Community

Emmanouil Liakos
Emmanouil Liakos

Posted on

10 2

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)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

Best practices for optimal infrastructure performance with Magento

Running a Magento store? Struggling with performance bottlenecks? Join us and get actionable insights and real-world strategies to keep your store fast and reliable.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️