-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
68 lines (63 loc) · 2.79 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: GitHub App Authentication
author: liblaf
description: This action authenticates with a GitHub App to generate an installation access token for specified repositories.
inputs:
app-id:
description: GitHub App ID
required: true
private-key:
description: GitHub App private key
required: true
owner:
description: The owner of the GitHub App installation (defaults to current repository owner)
required: false
default: ${{ github.repository_owner }}
repositories:
description: Comma or newline-separated list of repositories to install the GitHub App on (defaults to current repository if owner is unset)
required: false
outputs:
token:
description: GitHub installation access token
value: ${{ steps.app-token.outputs.token }}
installation-id:
description: GitHub App installation ID
value: ${{ steps.app-token.outputs.installation-id }}
app-slug:
description: GitHub App slug
value: ${{ steps.app-token.outputs.app-slug }}
commit-user-name:
description: Name used for the commit user
value: ${{ steps.app-token.outputs.app-slug }}[bot]
commit-user-email:
description: Email address used for the commit user
value: ${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com
commit-author:
description: Value used for the commit author. Defaults to the username of whoever triggered this workflow run.
value: ${{ steps.committer.outputs.string }}
runs:
using: composite
steps:
- name: Create GitHub App Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ inputs.app-id }}
private-key: ${{ inputs.private-key }}
owner: ${{ inputs.owner }}
repositories: ${{ inputs.repositories }}
# ref: <https://github.com/actions/create-github-app-token/blob/main/README.md#create-a-git-committer-string-for-an-app-installation>
- run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
shell: bash
name: Get GitHub App User ID
id: get-user-id
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- run: echo "string=${{ steps.app-token.outputs.app-slug }}[bot] <${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>" >> "$GITHUB_OUTPUT"
shell: bash
name: Create a git committer string for an app installation
id: committer
- 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
name: Configure git CLI for an app's bot user