Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub Action Get Commit Message

So I am building an action that does a build for a project that will go to Netlify. In the action I can pass a deploy message. In that deploy message, I want to pass in the commit message of the commit that triggered the build. I was looking at documentation but could not find if this is possible. Thanks

like image 636
jrock2004 Avatar asked Aug 27 '20 15:08

jrock2004


People also ask

How do I see commit messages in GitHub?

The short answer is, you cannot search commit messages directly on github.com the website. For the time being we recommend the local git grep solution others on this thread have proposed. At one point in time GitHub did offer a git grep style search over commit messages for a single repository.

How can I see last commit message?

Viewing a list of the latest commits. If you want to see what's happened recently in your project, you can use git log . This command will output a list of the latest commits in chronological order, with the latest commit first.

What is GitHub commit message?

A commit in GitHub is described as a saved change. A commit message explains what change you made to your project. It is greatly important to learn how to make a good commit message no matter if it is a personal or professional project.

How do you supply a message to a commit?

The easiest way to create a Git commit with a message is to execute “git commit” with the “-m” option followed by your commit message. When using the Git CLI, note that you should restrict your commit message in order for it not to be wrapped.


1 Answers

You can get the concrete commit message with the following command:

github.event.head_commit.message 

Or it is possible to get the commit messages with the git log command if you use bash:

git log -1 --pretty=format:"%s" 

Update: With regard to the documentation, the payload and thus also the call of the commit message has changed. The message can be fetched with the following line in the GitHub action:

github.event.commits[0].message 
like image 198
flaxel Avatar answered Sep 21 '22 05:09

flaxel