Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • Skip CI on readme.md file: https://stackoverflow.com/a/61876395/3764965
  • Skip CI on [skip ci] as a new GitHub feature:
    • https://stackoverflow.com/a/66156840/3764965 (answer here)
    • https://stackoverflow.com/a/66114678/3764965 (answer in another question)
  • Skip CI on [skip ci] message by parsing (customizable solution):
    • https://stackoverflow.com/a/59775665/3764965
  • Allow CI per specific branch: https://stackoverflow.com/a/61876395/3764965

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

like image 440
Nikolas Charalambidis Avatar asked Jan 15 '20 21:01

Nikolas Charalambidis


People also ask

How do I run jobs sequentially in GitHub Actions?

To run jobs sequentially, you can define dependencies on other jobs using the jobs. <job_id>. needs keyword. Each job runs in a runner environment specified by runs-on .

Do GitHub Actions jobs run in parallel?

You can configure a GitHub Actions workflow to be triggered when an event occurs in your repository, such as a pull request being opened or an issue being created. Your workflow contains one or more jobs which can run in sequential order or in parallel.

Is GitHub Actions better than Jenkins?

Using Jenkins allows you to store your code on any repository be on Github, Gitlab, BitBucket etc. Maturity: Jenkins has been around and is more mature than Github Actions. Github actions are relatively new and as a result, have less community support.


1 Answers

UPDATE: Please accept Helmisek anwser, which points out that Github has the functionality built-in now.

My answer only makes sense, if you want to skip just some jobs/steps.


You can give the following a try:

name: Maven Build on: [push]  jobs:   build:     if: "!contains(github.event.commits[0].message, '[skip ci]')"     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 
like image 186
scthi Avatar answered Sep 17 '22 20:09

scthi