| Comments

One of the things that I like about Azure DevOps Pipelines is the ability to make minor changes to your code/branch but not have full CI builds happening.  This is helpful when you are updating docs or README or things like that which don’t materially change the build output.  In Pipelines you have the built-in functionality to put some comments in the commit message that trigger (or don’t trigger rather) the CI build to stop.  The various ones that are supported are identified in ‘Skipping CI for individual commits’ documentation.

Today that functionality isn’t built-in to GitHub Actions, but you can add it as a base part of your workflows with the help of being able to get to the context of the commit before a workflow starts!  Here is an example of my workflow where I look for it:

name: .NET Core Build and Deploy

on:
  push:
    branches:
      - master

jobs:
  build:
    if: github.event_name == 'push' && contains(toJson(github.event.commits), '***NO_CI***') == false && contains(toJson(github.event.commits), '[ci skip]') == false && contains(toJson(github.event.commits), '[skip ci]') == false
    name: Build Package 
    runs-on: ubuntu-latest

You can see at Line 10 that I’m looking at the commit message text for: ***NO_CI***, [ci skip], or [skip ci].  If any of these are present then the job there does not run.  It’s as simple as that!  Here is an example of my last commit where I just was updating the repo to include the build badge:

Screenshot of a commit message on GitHub

And you can see in the workflows that it was not run:

Screenshot of workflow status on GitHub

A helpful little tip to add to your workflows to give you that flexibility!  Hope this helps!

Please enjoy some of these other recent posts...

Comments