I am using [github-actions]. I have two worksflows:
- triggered on
pull_request - triggered on
push
on:
workflow_dispatch:
pull_request:
branches:
- master
on:
workflow_dispatch:
push:
branches:
- master
The pull_request workflow generates assets that need be used in push workflow. I need some sort of an identifier that would allow me to connect the two workflows, ideally SHA of git merge commit. However, I was not able to identify a reliable reference to use.
At the moment I am using ${{ github.event.pull_request.head.sha }} in pull_request workflow, and in push workflow I am using:
- name: Setup repository
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Set CI_COMMIT_SHORT_SHA env property
shell: bash
run: echo "CI_COMMIT_SHORT_SHA=$(git rev-parse --short=8 HEAD^2)" >> $GITHUB_ENV
This works most of the time but breaks when commits are force pushed to the PR branch before it is merged.
What is a reliable git reference to associate pull_request with push workflows?