I am trying to trigger our smoke tests after deployment is completed. Deployment could be done via any platform like vercel, GitHub, etc. I am listening for the deployment_status event from GitHub actions and if it is success, I get the PR details based on github.sha. Code as below:
name: Run Cypress Smoke Tests
on: [deployment_status]
....
steps:
- name: GitHub API Request
uses: octokit/request-action@v2.x
id: octokit
with:
route: GET /repos/:repository/commits/:commit_sha/pulls
mediaType: |
previews:
- antiope
- groot-preview
repository: ${{ github.repository }}
commit_sha: ${{github.sha}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
But sometimes github.sha is not correct. I get the value of commit ID from the merge branch instead of the actual repo as mentioned https://github.community/t/github-sha-not-the-same-as-the-triggering-commit/18286/2.
How do I get the correct branch name or PR number or commit ID for the deployment_status event?
Thanks in advance.