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

Output sha of committed changelog #200

Closed
CWSites opened this issue May 19, 2021 · 5 comments · Fixed by #275
Closed

Output sha of committed changelog #200

CWSites opened this issue May 19, 2021 · 5 comments · Fixed by #275
Assignees
Labels
status: pinned Should not be labeled as stale type: feature New feature or feature request
Projects

Comments

@CWSites
Copy link

CWSites commented May 19, 2021

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?

@CWSites CWSites added the type: question Further information is requested label May 19, 2021
@EndBug EndBug self-assigned this May 22, 2021
@EndBug EndBug added type: feature New feature or feature request and removed type: question Further information is requested labels May 22, 2021
@EndBug EndBug added this to To do in Main board via automation May 22, 2021
@EndBug
Copy link
Owner

EndBug commented 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

@stale
Copy link

stale bot commented Jun 11, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale Inactive issues and PRs label Jun 11, 2021
@EndBug EndBug added status: pinned Should not be labeled as stale and removed type: feature New feature or feature request labels Jun 11, 2021
@stale stale bot removed the status: stale Inactive issues and PRs label Jun 11, 2021
@EndBug EndBug added the type: feature New feature or feature request label Jun 11, 2021
Main board automation moved this from To do to Done Aug 24, 2021
@EndBug
Copy link
Owner

EndBug commented 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

@allcontributors
Copy link
Contributor

@EndBug

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

@CWSites
Copy link
Author

CWSites commented Dec 17, 2021

Hey @EndBug I appreciate your work here, would you be able to extend the sha output to be the full sha and not just the last 7 characters? I'm trying to use this on other actions which require the full sha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: pinned Should not be labeled as stale type: feature New feature or feature request
Projects
No open projects
Main board
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants