Skip to content

Instantly share code, notes, and snippets.

@ffflorian
Created August 4, 2020 14:17
Show Gist options
  • Save ffflorian/71de2e72a3788fbc63fa5ead8e3b5fde to your computer and use it in GitHub Desktop.
Save ffflorian/71de2e72a3788fbc63fa5ead8e3b5fde to your computer and use it in GitHub Desktop.
GH actions: Get commit message in a PR
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})"
@neotan
Copy link

neotan commented Jan 11, 2023

@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!

@3barroso
Copy link

3barroso commented Sep 5, 2024

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