Assume:
The latest commit's commit message of the branch feature/xyz
is add feature xyz
with SHA number 1234
. The newest commit's SHA number of the main branch is 3456
.
When I push the branch feature/xyz
to the repo and open a pull request from feature/xyz
to main
a workflow pipeline will be triggered, how can I get the commit message add feature xyz
?
note: the pull request is open and not merged
name: Dev deploy
on:
pull_request:
types: [opened, reopened, edited, synchronize]
jobs:
deploy-to-dev:
name: deploy to dev
runs-on: ubuntu-22.04
steps:
- name: checkout repo
uses: actions/checkout@v3
- name: Set env var
run: |
echo commit=$(git log --format=%B -n 1) >> $GITHUB_ENV
git log --format=%B -n 1
would give me something like Merge 1234 into 3456
.
How can I get the commit message of the last commit from the branch feature/xyz
, aka, add feature xyz
in this case?