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

Add custom source sha #126

Merged
merged 5 commits into from
Jul 14, 2021
Merged

Add custom source sha #126

merged 5 commits into from
Jul 14, 2021

Conversation

Kras4ooo
Copy link
Contributor

Why I did this PR

I hit the issue when I created PR and when I use:

      - name: Github checkout
        uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}
          fetch-depth: 0

When we use github.head_ref we checkout the current branch. But after that the script gets github.sha but the value of sha is not equal to the PR value, so we have difference between the branch sha and the github.sha. I receive similar error:

  fatal: bad object 75e655dddc4f3eb8c0748b95bdd1a44f3a758b0f
  fatal: bad object 75e655dddc4f3eb8c0748b95bdd1a44f3a758b0f
  fatal: bad object 75e655dddc4f3eb8c0748b95bdd1a44f3a758b0f
  fatal: bad object 75e655dddc4f3eb8c0748b95bdd1a44f3a758b0f
  fatal: bad object 75e655dddc4f3eb8c0748b95bdd1a44f3a758b0f
  fatal: bad object 75e655dddc4f3eb8c0748b95bdd1a44f3a758b0f
  fatal: bad object 75e655dddc4f3eb8c0748b95bdd1a44f3a758b0f
  fatal: bad object 75e655dddc4f3eb8c0748b95bdd1a44f3a758b0f
  fatal: bad object 75e655dddc4f3eb8c0748b95bdd1a44f3a758b0f

With this PR we can pass the source sha and now I can pass the correct sha for the source branch and all works well.

Why I use: export GITHUB_SHA=${{ inputs.sha != '' && inputs.sha || github.sha }} vs GITHUB_SHA=${{ inputs.sha != '' && inputs.sha || github.sha }} in env section: When we use env section we pass variable but after that the Github action override GITHUB_SHA and in order to avoid this I just add export right before entrypoint execution.

.github/workflows/test.yml Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
action.yml Outdated Show resolved Hide resolved
action.yml Outdated Show resolved Hide resolved
@jackton1
Copy link
Member

@Kras4ooo Thanks for implementing this fix added some updates that would be required.

@jackton1
Copy link
Member

@all-contributors add @Kras4ooo for code and documentation

@allcontributors
Copy link
Contributor

@jackton1

I've put up a pull request to add @Kras4ooo! 🎉

@jackton1 jackton1 merged commit 53afe7a into tj-actions:main Jul 14, 2021
@jackton1
Copy link
Member

jackton1 commented Jul 15, 2021

@Kras4ooo This should be available in the latest v8.5 release. Thanks

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 this pull request may close these issues.

2 participants