Search code examples
gitgithubcontinuous-integrationjobsgithub-actions

How to skip GitHub Actions job on push event?


With Travis CI, we can skip the build for a particular commit with adding a suffix to a commit. This is described at Travis CI. I find this feature practical when I only edit README.md which is not code-related and the pre-flight build doesn't need to be triggered.

[skip ci]

How do I skip the jobs trigged on: push events using GitHub Actions?

name: Maven Build
on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - name: Check-out project
      uses: actions/checkout@v1
    - name: Set up JDK 11.0.3
      uses: actions/setup-java@v1
      with:
        java-version: 11.0.3
    - name: Build with Maven
      run: mvn -B package --file pom.xml

Answers summary:

Big thanks to all the answerers providing various ways to achieve it. I bet everybody would need something a little bit different regarding to the origin of their problem and the CI approach. Here are the answers listed for a quick navigation:

All the answers deserve upvote! If you like my question, you should double-like the answers.


Solution

  • Also, for files and directories you want ignored on all pushes you can configure the workflow itself:

    on:
      push:
        paths-ignore:
        - 'README.md'