#DevHack: Skip GitHub Actions on specific commits messages
This post is over a year old, some of this information may be out of date.
In the doctor
project, I try to do as much as possible in one GitHub Actions workflow. Having all logic in one workflow makes it more convenient but comes with a couple of complexities. Like, do you want to run each action for every type of commit/PR/…?

Why I want to skip actions/jobs in my workflow
I host the documentation on Vercel. Vercel manages its build processes. You can also choose to use the Vercel Action for deploying your sources, but having it on the Vercel platform itself is straightforward.
When I was working on the documentation, I thought it would be useless to go through a complete workflow run when only the documentation was touched. I thought this does not have to happen, so why not skip these actions/jobs on specific commits. That is why I specified to skip all jobs when my commit contains #docs
in the commit message.
Skipping when commits contain a text value
If you want to skip your job or actions when the commit contains a specific text value in its commit message, all you have to do is add an if
condition. In this condition, you can use the contains
expression.
In the case of my #docs
commit messages, the expression looks as follows:
jobs: build: name: Build ${{ matrix.os }} - Bash runs-on: ${{ matrix.os }} if: ${{ !contains(github.event.head_commit.message, '#docs') }}

Happy automating
Related articles
Report issues or make changes on GitHub
Found a typo or issue in this article? Visit the GitHub repository to make changes or submit a bug report.
Comments
Let's build together
Manage content in VS Code
Present from VS Code