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 long_sha output #341

Closed
EndBug opened this issue Dec 17, 2021 · 9 comments · Fixed by #349
Closed

Add long_sha output #341

EndBug opened this issue Dec 17, 2021 · 9 comments · Fixed by #349
Assignees
Labels
status: pinned Should not be labeled as stale type: feature New feature or feature request

Comments

@EndBug
Copy link
Owner

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

Originally posted by @CWSites in #200 (comment)

@EndBug
Copy link
Owner Author

EndBug commented Dec 17, 2021

@CWSites it sure is something that I could add!

In the meanwhile, you can get the full sha with git rev-parse. Here's a sample step you can use:

- uses: EndBug/add-and-commit@...
  id: commit
  ...

- id: helper
  run: echo "::set-output name={long_sha}::{$(git rev-parse ${{ steps.commit.outputs.commit_sha }})}"

- name: Your other step
  run: echo ${{ steps.helper.outputs.long_sha }}

If I didn't make any typos, this should be a workaround: the helper step sets a long_sha output with the result of the git rev-parse command, that you can later use as an input.

@EndBug EndBug self-assigned this Dec 17, 2021
@EndBug EndBug added status: pinned Should not be labeled as stale type: feature New feature or feature request labels Dec 17, 2021
@EndBug EndBug added this to To do in Main board via automation Dec 17, 2021
@CWSites
Copy link

CWSites commented Dec 17, 2021

Thanks for the quick response, I'm testing this out now.

@CWSites
Copy link

CWSites commented Dec 17, 2021

I must be doing something wrong here, I'm getting back 0. I'm generating a changelog then trying to commit the updated file. Here is my config.

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Generate Changelog
        uses: fabernovel/github-changelog-generator-action@master
        with:
          # https://github.com/github-changelog-generator/github-changelog-generator/wiki/Advanced-change-log-generation-examples#additional-options
          options: --token ${{ secrets.GITHUB_TOKEN }} --date-format %m/%d/%Y --output CHANGE_LOG.md --enhancement-label **Features:** --enhancement-labels enhancement --bug-labels defect --exclude-labels documentation,question,release --breaking-labels BREAKING-CHANGE --since-tag 1.0.0 --unreleased-label Current Release

      # https://github.com/marketplace/actions/add-commit
      - name: Commit and Push Changelog
        uses: EndBug/add-and-commit@v7.4.0
        with:
          add: CHANGE_LOG.md
          default_author: github_actions
          message: 'Update Changelog'

      - name: Generate Changelog SHA
        id: changelog-sha
        run: echo "::set-output name={long_sha}::{$(git rev-parse ${{ steps.commit.outputs.commit_sha }})}"

      - name: Print Changelog SHA
        run: echo ${{ steps.changelog-sha.outputs.long_sha }}

The output that I'm getting in my action is
Screen Shot 2021-12-17 at 3 06 38 PM

@EndBug
Copy link
Owner Author

EndBug commented Dec 17, 2021

You forgot to add id: commit to the add-and-commit step

@CWSites
Copy link

CWSites commented Dec 18, 2021

Ohhh I see, thank you! Trying this now

@CWSites
Copy link

CWSites commented Dec 18, 2021

Alrighty, we are getting closer...

      - name: Commit and Push Changelog
        id: commit
        uses: EndBug/add-and-commit@v7.4.0
        with:
          add: CHANGE_LOG.md
          default_author: github_actions
          message: 'Update Changelog'

      - name: Generate Changelog SHA
        id: changelog-sha
        run: echo "::set-output name={long_sha}::{$(git rev-parse ${{ steps.commit.outputs.commit_sha }})}"

      - name: Print Changelog SHA
        run: echo ${{ steps.changelog-sha.outputs.long_sha }}

The first part is showing the short SHA, the long output is still showing {0} though.

Screen Shot 2021-12-17 at 8 31 35 PM

@EndBug
Copy link
Owner Author

EndBug commented Dec 19, 2021

Maybe it's the - in the id name (?)

@CWSites
Copy link

CWSites commented Dec 20, 2021

No joy, same output as above with {0}

      - name: Commit and Push Changelog
        id: commit
        uses: EndBug/add-and-commit@v7.4.0
        with:
          add: CHANGE_LOG.md
          default_author: github_actions
          message: 'Update Changelog'

      - name: Generate Changelog SHA
        id: generate_sha
        run: echo "::set-output name={long_sha}::{$(git rev-parse ${{ steps.commit.outputs.commit_sha }})}"

      - name: Print Changelog SHA
        run: echo ${{ steps.generate_sha.outputs.long_sha }}

@EndBug
Copy link
Owner Author

EndBug commented Jan 20, 2022

This feature has been added in v8.0.0 (also v8 and latest). Thanks for your issue!

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
None yet
Development

Successfully merging a pull request may close this issue.

2 participants