Skip to content

Getting the last commit message into the run command #27193

Discussion options

You must be logged in to vote
KoalaTeaSoftware:

I nearly got there with set-env, but that is deprecated.

It has been replaced by the GITHUB_ENV environment file. The other thing you need to know is that in Bash you can use $(command) to substitute the output of command. So to set a COMMIT_MSG environment variable for use in later steps:

- name: get commit message
  run: |
    echo "COMMIT_MSG=$(git log -1 --pretty=format:%s)" >>$GITHUB_ENV

Or if you need the output only for the sed command you could skip the variable and just do something like:

- name: substitute log message
  run: |
   sed -e "s/@COMMIT_MSG@/$(git log -1 --pretty=format:%s)/" project.properties.in >project.properties

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants