From 59d06ffc98b400e278b80a5359e07250c886d993 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 27 Nov 2024 00:54:48 +0100 Subject: [PATCH 1/2] chore: add a github action for setting up the bot app --- actions/setup-bot-token/action.yml | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 actions/setup-bot-token/action.yml diff --git a/actions/setup-bot-token/action.yml b/actions/setup-bot-token/action.yml new file mode 100644 index 00000000..1eb33b35 --- /dev/null +++ b/actions/setup-bot-token/action.yml @@ -0,0 +1,34 @@ +name: Setup app bot +description: Gets a github app token and configures git with the app's user +inputs: + app_id: + description: The app id + required: true + app_private_key: + description: The app private key + required: true +outputs: + token: + description: The token to use for the GitHub App + value: ${{ steps.app-token.outputs.token }} +runs: + using: "composite" + steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ inputs.app_id }} + private-key: ${{ inputs.app_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" + shell: bash + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + + - name: Set up Git + 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>' + shell: bash From 527e5c379f0213ea5ea77a92b9393f6891b70a13 Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Wed, 27 Nov 2024 01:15:30 +0100 Subject: [PATCH 2/2] Rename arguments to match create-github-app-token --- actions/setup-bot-token/action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/actions/setup-bot-token/action.yml b/actions/setup-bot-token/action.yml index 1eb33b35..14570760 100644 --- a/actions/setup-bot-token/action.yml +++ b/actions/setup-bot-token/action.yml @@ -1,10 +1,10 @@ name: Setup app bot description: Gets a github app token and configures git with the app's user inputs: - app_id: + app-id: description: The app id required: true - app_private_key: + private-key: description: The app private key required: true outputs: @@ -17,8 +17,8 @@ runs: - uses: actions/create-github-app-token@v1 id: app-token with: - app-id: ${{ inputs.app_id }} - private-key: ${{ inputs.app_private_key }} + app-id: ${{ inputs.app-id }} + private-key: ${{ inputs.private-key }} - name: Get GitHub App User ID id: get-user-id