Skip to content

Instantly share code, notes, and snippets.

@ybiquitous
Last active February 9, 2021 10:11
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ybiquitous/c80f15c18319c63cae8447a3be341267 to your computer and use it in GitHub Desktop.
Save ybiquitous/c80f15c18319c63cae8447a3be341267 to your computer and use it in GitHub Desktop.
How to "[skip ci]" on GitHub Actions
# See also:
# - https://github.com/actions/runner/issues/774
# - https://help.github.com/en/actions/reference/events-that-trigger-workflows#push-event-push
# - https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request
# - https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions
name: "[skip ci]" on Actions
on: [push, pull_request]
jobs:
check_skip:
runs-on: ubuntu-latest
if: |
!contains(format('{0} {1}', github.event.head_commit.message, github.event.pull_request.title), '[skip ci]')
steps:
- run: |
echo 'github.event_name: ${{ github.event_name }}'
echo 'github.event:'
echo '${{ toJson(github.event) }}'
build:
needs: check_skip
runs-on: ubuntu-latest
steps:
- run: echo 'Hi!'
@dscho
Copy link

dscho commented May 2, 2020

I fear that join(github.event.pull_request.title, github.event.pull_request.body) does not quite do what you'd expect it to do: it uses the second parameter as separator. But since the first parameter is not an array, that separator is never used. See https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#join for details.

@dscho
Copy link

dscho commented May 2, 2020

(The best workaround I could come up with is to use format('{0} {1}', github.event.pull_request.title, github.event.pull_request.body).)

@ybiquitous
Copy link
Author

@dscho Thanks a lot for your advice! As you pointed out, my usage of the join() function was wrong. ๐Ÿ˜…

I've updated the file, so I would be appreciated if it could help you. ๐Ÿ˜Š

@ThatXliner
Copy link

How do I use this?

@ybiquitous
Copy link
Author

@ybiquitous
Copy link
Author

Usage

For pull requests

Include [skip ci] to a pull request title.

For commit pushes

Include [skip ci] to a commit message.

@ybiquitous
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment