Skip to content

github.sha isn't the value expected #25191

Discussion options

You must be logged in to vote

@anderspitman When a workflow is triggered by pull request event, the github.ref will be refs/pull/<id>/merge. And the github.sha will be the pre merge commit id. If you have a pull request from dev to master, github.sha is not the commit which you pushed to dev.  

You need to use github.event.pull_request.head.sha to get the commit id which you pushed to dev. 

And based on my test when the workflow is triggered by push to master,  comment PR step will fail. 

So you could change your workflow file to 

name: CI
on:
  pull_request:
    branches: [master]

jobs:
example:
name: sample comment
runs-on: ubuntu-latest
steps:
- name: comment PR
uses: unsplash/comment-…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@wheelerlaw
Comment options

Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@RomeroGaliza
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants