๐Ÿ“ฆ veggiemonk / skip-commit

GitHub Action: skip based on the last commit message containing a string

โ˜… 58 stars โ‘‚ 2 forks ๐Ÿ‘ 58 watching โš–๏ธ MIT License
actionactionsgithub-actiongithub-actions
๐Ÿ“ฅ Clone https://github.com/veggiemonk/skip-commit.git
HTTPS git clone https://github.com/veggiemonk/skip-commit.git
SSH git clone git@github.com:veggiemonk/skip-commit.git
CLI gh repo clone veggiemonk/skip-commit
Julien Bisconti Julien Bisconti Add link to cancel-workflow-action 90b1c24 5 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“„ Dockerfile
๐Ÿ“„ entrypoint.sh
๐Ÿ“„ LICENSE
๐Ÿ“„ README.md
๐Ÿ“„ README.md

GitHub Actions to skip based on commit message (UNMAINTAINED)

If the last commit message contains the string skip-ci, the action will stop.

You might want to check out this repository: https://github.com/styfle/cancel-workflow-action

Just use YAML (recommended)

Thank to @smnbbrv who kindly shared this solution with us here

jobs:
  main:
    name: Build and test
    runs-on: ubuntu-latest
    if: "!contains(github.event.head_commit.message, 'ci skip')"

Just use BASH

- name: should it be skipped?
    env:
      COMMIT_FILTER: "skip-ci"
    run: | 
      # Get last commit message
      readonly local last_commit_log=$(git log -1 --pretty=format:"%s")
      echo "last commit log: $last_commit_log"

      readonly local filter_count=$(echo "$last_commit_log" | grep -c "$COMMIT_FILTER" )
      echo "number of occurence of '$COMMIT_FILTER' in '$last_commit_log': $filter_count"

      if [[ "$filter_count" -eq 0 ]]; then
        echo "all good, continue"
      else
        echo "the last commit log \"$last_commit_log\" contains \"$COMMIT_FILTER\", stopping"
        exit 78
      fi

Or use the container (not recommended / deprecated)

If a commit message contains a string defined as the environment variable $COMMIT_FILTER, the action will stop.

For example:

action "Skip" {
  uses = "veggiemonk/skip-commit@master"
  env = {
    COMMIT_FILTER = "skip-ci"
  }
}