Get the last commit message and store it to an env variable in actions/checkout@v2 #25376
-
As title. How can I get the last commit message and store it to an env variable in actions/checkout@v2 |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Hi @sblantipodi , The last commit message can be got from Github context : ${{ github.event.head_commit.message }} , and set it as env as below:
BTW, actions/checkout doesn’t need env setting since not related code are defined, the env won’t be invoked for the action, unless you rewrite the code to invoke the env variable. Thanks. |
Beta Was this translation helpful? Give feedback.
-
thanks for the answer but this code prints an empty message.
any help is much appreciated. :slight_smile: thanks. |
Beta Was this translation helpful? Give feedback.
-
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:
Or you can use ‘set-env’ to set/update the env variables. Code sample as below:
Thanks. |
Beta Was this translation helpful? Give feedback.
-
Hey, @weide-zhou |
Beta Was this translation helpful? Give feedback.
-
Hi @zanona, The value comes from github context, please check the doc here: https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context You can export the github context with below code for your workflow:
It will output github context as json format, then you can follow the structure to get the content you required. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Please notice that |
Beta Was this translation helpful? Give feedback.
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:
Or you can use ‘set-env’ to set/update the env variables. Code sample as below: