From 6afbd4bfa2959323c2a76604632dabd00c885885 Mon Sep 17 00:00:00 2001 From: "Yamamoto, Hirotaka" Date: Thu, 18 Sep 2025 16:32:26 +0900 Subject: [PATCH 1/2] Update procedure to configure git --- README.md | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f969916..f1c502e 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,14 @@ jobs: - run: echo "committer string is ${{ steps.committer.outputs.string }}" ``` -### Configure git CLI for an app's bot user +> [!TIP] +> The `` is the numeric user ID of the app's bot user, which can be found under `https://api.github.com/users/%5Bbot%5D`. +> +> For example, we can check at `https://api.github.com/users/dependabot[bot]` to see the user ID of Dependabot is 49699333. +> +> Alternatively, you can use the [octokit/request-action](https://github.com/octokit/request-action) to get the ID. + +### Configure gh/git CLI for an app's bot user ```yaml on: [pull_request] @@ -104,28 +111,17 @@ jobs: # required app-id: ${{ vars.APP_ID }} private-key: ${{ secrets.PRIVATE_KEY }} - - name: Get GitHub App User ID - id: get-user-id - run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} + permission-contents: write - run: | - git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' - git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com' - # git commands like commit work using the bot user + echo "${{ steps.app-token.outputs.token }}" | gh auth login --with-token + gh auth setup-git + # git commands like commit and push work using the bot user - run: | git add . git commit -m "Auto-generated changes" git push ``` -> [!TIP] -> The `` is the numeric user ID of the app's bot user, which can be found under `https://api.github.com/users/%5Bbot%5D`. -> -> For example, we can check at `https://api.github.com/users/dependabot[bot]` to see the user ID of Dependabot is 49699333. -> -> Alternatively, you can use the [octokit/request-action](https://github.com/octokit/request-action) to get the ID. - ### Create a token for all repositories in the current owner's installation ```yaml From 1fe16e0e91bba8f6176fc339cfa2c5ca9c8bed07 Mon Sep 17 00:00:00 2001 From: ymmt Date: Thu, 18 Sep 2025 20:27:56 +0900 Subject: [PATCH 2/2] fix --- README.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f1c502e..869e22e 100644 --- a/README.md +++ b/README.md @@ -89,13 +89,6 @@ jobs: - run: echo "committer string is ${{ steps.committer.outputs.string }}" ``` -> [!TIP] -> The `` is the numeric user ID of the app's bot user, which can be found under `https://api.github.com/users/%5Bbot%5D`. -> -> For example, we can check at `https://api.github.com/users/dependabot[bot]` to see the user ID of Dependabot is 49699333. -> -> Alternatively, you can use the [octokit/request-action](https://github.com/octokit/request-action) to get the ID. - ### Configure gh/git CLI for an app's bot user ```yaml @@ -112,7 +105,14 @@ jobs: app-id: ${{ vars.APP_ID }} private-key: ${{ secrets.PRIVATE_KEY }} permission-contents: write + - name: Get GitHub App User ID + id: get-user-id + run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} - run: | + git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' + git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com' echo "${{ steps.app-token.outputs.token }}" | gh auth login --with-token gh auth setup-git # git commands like commit and push work using the bot user @@ -122,6 +122,13 @@ jobs: git push ``` +> [!TIP] +> The `` is the numeric user ID of the app's bot user, which can be found under `https://api.github.com/users/%5Bbot%5D`. +> +> For example, we can check at `https://api.github.com/users/dependabot[bot]` to see the user ID of Dependabot is 49699333. +> +> Alternatively, you can use the [octokit/request-action](https://github.com/octokit/request-action) to get the ID. + ### Create a token for all repositories in the current owner's installation ```yaml