Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot get correct short sha for pull requests #30

Closed
masterkain opened this issue Feb 8, 2021 · 3 comments · Fixed by #48
Closed

cannot get correct short sha for pull requests #30

masterkain opened this issue Feb 8, 2021 · 3 comments · Fixed by #48
Assignees

Comments

@masterkain
Copy link

masterkain commented Feb 8, 2021

I have a workflow based on this:

on:
  pull_request:
    types: [opened, reopened, closed]

    steps:
      - name: GitHub Environment Variables Action
        uses: FranzDiebold/github-env-vars-action@v2.1.0

and I'm using SHA8: ${{ env.CI_SHA_SHORT }} in my job

however the resulting SHA is not something that I can use, it does not correspond to anything in the repo.

@FranzDiebold
Copy link
Owner

FranzDiebold commented Feb 8, 2021

Hi @masterkain,

I'm happy to help! 💪

The action uses the default environment variable GITHUB_SHA to calculate the shortened SHA.
In case of the pull_request event, the GITHUB_SHA is the commit SHA of the "last merge commit on the GITHUB_REF branch". Thus, the CI_SHA_SHORT is the shortened SHA thereof.

For demonstration purposes I made a demo PR from a demo branch: In this case the GITHUB_SHA / CI_SHA_SHORT is 359d607f52a27ecf4d1bde20012064781ec3a2c3. The corresponding commit is the following: 359d607.
As we can see, it is an existing commit SHA, but unfortunately neither the commit SHA of the base nor the head branch.
Since I am using default environment variables from GitHub in this action I cannot provide any other commit SHA. 🤷

Can I close the issue?

@masterkain
Copy link
Author

hello,
thanks for providing more info and thanks for the action!

@FranzDiebold FranzDiebold self-assigned this Apr 12, 2021
iamstarkov added a commit to iamstarkov/github-env-vars-action that referenced this issue Jul 12, 2022
Default CI_SHA/GITHUB_SHA is the sha of _expect-to-be_ merge/squash/etc commit of the pull requests,
and it can be very confusing. If you mark you artifacts with it, its very hard to trace back what was the actual commit.

CI_PR_SHA is the way I solved it for my use cases and I can see im not the first one with this problem.

Fixes FranzDiebold#30
@iamstarkov
Copy link
Contributor

@masterkain were you looking for something like this? #48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants