I am attempting to push code to a GitHub repository from a workflow run in GitHub Actions Beta (the YAML ones). This is easy to do by just running git push
after setting the origin
remote URL to one containing credentials, so that Git knows how to authenticate with GitHub.
GitHub Actions even get a PAT out of the box: GITHUB_TOKEN
, which can be used and the whole system is smart enough to know not to schedule another action when commits are pushed to a repository using a PAT known to be associated with a previous workflow run.
This is great, however, there are use-cases for using a custom PAT (in my case to trigger GitHub Pages to build, which the out of the box PAT won't do) and using custom PAT loses the advantage of having GitHub know not to run another workflow after pushing commits from the current one.
As a result, one finds themselves in an infinite loop of workflows when using a custom PAT. Many CI solutions honor ***NO_CI***
in a commit message and won't run any checks/builds/whatever if this string is present in the commit message. GitHub Actions Beta do not care about it.
The only thing I could come up with is to make the GitHub Action workflow job/step conditional and construct a condition like this:
- if: !contains(github.commit_message, "***NO_CI***")
However the github
context object does not have a field that would contain the commit message and the contexts do not seem to be expressive enough to allow me to run a command to obtain the commit message from the SHA using Git and run the contains
on that.
Do I have any options to achieve this?