I've done a lot of searching, and what I'm seeing is confusing. What I need, I think, should be relatively simple. I have an action that handles deployments to multiple environments (qa, uat, prod). When we merge to main a deployment goes out to QA automatically, but UAT requires approval, as does prod. The deploy is done to heroku which is done via a git push to the heroku remote. So, what can happen is while waiting for approval there will be more merges to main. Then when we approve from the previous action it will deploy main in it's current entirety instead of from the commit sha of the merge that the approval is tied to. So I want to modify my action so the push to heroku uses the commit sha for the specific merge. I can't figure out how to get the commit sha for the merge commit in a github push action. A simplified version would look something like this:
name: deploy
on:
push:
branches:
- main
jobs:
deploy-to-uat:
uses ./.github/workflows/deploy-to-heroku.yml
with:
heroku-env: 'uat'
commit-sha: [[SOMEHOW GET THE MERGE COMMIT SHA HERE]]
The deploy-to-heroku workflow would then have the correct commit sha so I can use that to push a specific ref representing the point at which the merge happened up to heroku instead of just the head.
The github
context has this available:
${{ github.sha }}
in expressions$GITHUB_SHA
in the environmentSo, for your example, you could pass it in like
jobs:
deploy-to-uat:
uses: ./.github/workflows/deploy-to-heroku.yml
with:
heroku-env: 'uat'
commit-sha: ${{ github.sha }}
(fixed indentation and missing :
)
or you can just reference it in deploy-to-heroku.yml
directly as it's the same as in the caller workflow.