Skip to content

Get the last commit message and store it to an env variable in actions/checkout@v2 #25376

Answered by weide-zhou
sblantipodi asked this question in Actions
Discussion options

You must be logged in to vote

Hi @sblantipodi ,

Thanks for your quick reply! This is a step level env which only works in checkout step.

If you’d like to use the env variable in the other steps, please set it as job level env, code sample as below:

jobs:
  job1:
    env:
      commitmsg: ${{ github.event.head_commit.message }}
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v2
      - name: get commit message
        run: |
            echo Commit MSG = ${{ env.commitmsg }}

Or you can use ‘set-env’ to set/update the env variables. Code sample as below:

- name: set the head commit message as env
        run: |
          echo '::set-env nam…

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

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

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
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
4 participants