Created
August 4, 2020 14:17
-
-
Save ffflorian/71de2e72a3788fbc63fa5ead8e3b5fde to your computer and use it in GitHub Desktop.
GH actions: Get commit message in a PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Notify on Pull Request | |
on: | |
pull_request: | |
branches: [dev] | |
jobs: | |
send_notification: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
ref: ${{github.event.after}} | |
- name: Get Commit Message | |
run: | | |
MSG=$(git log --format=%B -n 1 ${{github.event.after}}) | |
echo "::set-env name=COMMIT_MESSAGE::${MSG}" | |
- name: Echo commit message | |
run: echo "Commit SHA: ${{github.event.after}}, commit message: ${{env.COMMIT_MESSAGE}} (or ${COMMIT_MESSAGE})" |
In case someone landed here for a quick solution. The ${{ github.event.head_commit.message }}
is still working fine. FYI.
@neotan no, it doesn't work in PR events as mentioned above (only push). I came here because it doesn't work in PR events.
@neotan no, it doesn't work in PR events as mentioned above (only push).
ah, my bad! Overlooked the mentions above, ya it works in pushing. Thanks for pointing out!
This thread helped me get where I needed to go!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks so much 👍