Uh oh!
There was an error while loading. Please reload this page.
docs(README): fix committer string example and add git config example - #145
Conversation
gr2m
left a comment
There was a problem hiding this comment.
thank you! Document fix PRs are the best PRs 💐
I think we can list both examples. There are use cases that require the commit string, e.g. some actions. If you'd like to add another example on how to configure git using outputs of this action, that'd be great |
Uh oh!
There was an error while loading. Please reload this page.
Indeed, Here's how my bot signature is generated. functionset_dco_signature {
if [[ $TOKEN== ghp_* ]];then# https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/# What starts with 'ghp_' is the GitHub personal access token
response=$(curl -s -H "Authorization: token $TOKEN""$GITHUB_URL/user")elif [[ $APP_SLUG ]];then
CommitBot=$APP_SLUGelse
CommitBot="github-actions"fiif [[ $CommitBot ]];then
response=$(curl -s -H "Authorization: token $TOKEN""$GITHUB_URL/users/$CommitBot\[bot\]")fi
CommitBot=$(echo "$response"| jq -r '.login')
id=$(echo "$response"| jq -r '.id')echo"Signed-off-by: $CommitBot <$id+$CommitBot@users.noreply.github.com>"
}By the way, I'd like to share my own submission script based on Usage example: |
maboloshi
commented
Jun 27, 2024
Based on the ### Configure git CLI for an app's bot user```yamlon: [pull_request]jobs:
auto-format:
runs-on: ubuntu-lateststeps:
- uses: actions/create-github-app-token@v1id: app-tokenwith:
# requiredapp-id: ${{ vars.APP_ID }}private-key: ${{ secrets.PRIVATE_KEY }}
- uses: octokit/request-action@v2id: get-bot-idwith:
route: GET /users/${{ steps.app-token.outputs.app-slug }}[bot]env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: | git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' git config --global user.email '${{ fromJson(steps.get-bot-id.outputs.data).id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>'# git commands like commit work using the bot user
- run: | git add . git commit -m "Auto-generated changes" git push |
anuraaga
commented
Jun 27, 2024
Yeah I considered using |
gr2m
commented
Jun 27, 2024
using the |
vleon1a
commented
Jun 27, 2024
I tried with the GH CLI, it works like a charm: - name: Generate GitHub App Tokenid: generate-tokenuses: actions/create-github-app-token@ad38cffc07bac6e3857755914c4c88bfd2db4da4 # v1.10.2with:
app-id: ${{ secrets.SEMANTIC_RELEASE_APP_ID }}private-key: ${{ secrets.SEMANTIC_RELEASE_PRIVATE_KEY }}
- name: Retrieve GitHub App User IDid: get-user-idenv:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}run: echo "user-id=$(gh api "/users/${{ steps.generate-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
- name: GitHub Releaseid: semantic-releaseenv:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}GIT_AUTHOR_NAME: ${{ steps.generate-token.outputs.app-slug }}[bot]GIT_AUTHOR_EMAIL: ${{ steps.get-user-id.outputs.user-id }}+${{ steps.generate-token.outputs.app-slug }}[bot]@users.noreply.github.comGIT_COMMITTER_NAME: ${{ steps.generate-token.outputs.app-slug }}[bot]GIT_COMMITTER_EMAIL: ${{ steps.get-user-id.outputs.user-id }}+${{ steps.generate-token.outputs.app-slug }}[bot]@users.noreply.github.comrun: npx semantic-release |
anuraaga
commented
Jun 28, 2024
Thanks all, I have gone ahead and updated the doc to use |
maboloshi
commented
Jun 28, 2024
This part has not been corrected.😊 |
anuraaga
commented
Jun 28, 2024
Ah wasn't sure if it's ok to update the existing doc, went ahead and did it. Thanks |
gr2m
left a comment
There was a problem hiding this comment.
Great work @anuraaga and @maboloshi, thank you 💐
🎉 This PR is included in version 1.10.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
I noticed the referenced ID in the committer string example doesn't seem to be correct.
Unrelated to this fix, I was wondering if there is interest in tweaking the example to be used with
git config? I feel as if that is more generally useful than just echoing the string. For exampleIt is the same content as the current example but ready to go for a common use case IMO.