question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Output `sha` of committed changelog

See original GitHub issue

In my workflow I’m generating a changelog and using this action to commit the generated code back to my repo. After it’s generated I’m creating a release in GitHub and publishing to NPM. Currently my workflow is using the original sha prior to this committing files back to my repo which is causing some issues.

What I’m looking for here is an output of the sha which includes the commit created by this action?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
EndBugcommented, May 22, 2021

Hi, this would be a nice addition to the already existing outputs!

In the meantime, here’s a manual way to do it: you’ll need to set up a step that outputs the current HEAD sha retrieved from git. You can try something like this:

# ...

- uses: EndBug/add-and-commit@v7
  # ...

- id: head_commit
  run: echo "::set-output name=commit_sha::$(git rev-parse HEAD)"
  shell: bash

- run: echo {{ steps.head_commit.outputs.commit_sha }}

Explanation:

  • The step you set up needs to have a custom id, so that you can look it up later.
  • To get the string containing the commit sha associated with HEAD (your latest commit), you need to use git rev-parse HEAD (ref, docs)
  • In order to set an output using this value, you’ll need to use a workflow command
  • After setting the output, you can get its value in other steps by using an expression that uses the steps context
1reaction
EndBugcommented, Aug 24, 2021

Sorry it took me so long to get to this even though it was really easy to implement 😅

@all-contributors please add @CWSites for their idea

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I see the changes in a Git commit? - Stack Overflow
The following seems to do the job; I use it to show what has been brought in by a merge. git whatchanged -m...
Read more >
Links to SHA commits in release notes don't display in ... - GitLab
Links to SHA commits in release notes don't display in the new Releases page (but do display on the Tags page). When you've...
Read more >
2.3 Git Basics - Viewing the Commit History
As you can see, this command lists each commit with its SHA-1 checksum, the author's name and email, the date written, and the...
Read more >
Commit SHAs and Undoing Commits (How To) - Treehouse
Git can even undo all the changes from a commit for you, with a command ... With git revert, the SHA is used...
Read more >
Viewing the commit history of a Git repository - DeployHQ
See how to view recent commits and the changes for a specific commit hash. ... This command will output a list of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found