forked from summerwind/gh-app-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
45 lines (45 loc) · 1.54 KB
/
action.yml
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
name: gh-app-auth
description: Authenticate with the GitHub App and generate the installation token
inputs:
app-id:
description: GitHub App ID
required: true
private-key:
description: GitHub App private key
required: true
account:
description: Target account name
required: true
version:
description: Version to install
default: "0.1.1"
required: false
outputs:
token:
description: Installation token
value: ${{ steps.auth.outputs.token }}
runs:
using: composite
steps:
- id: install
shell: bash
working-directory: /tmp
run: |
set -e
VERSION="${{ inputs.version }}"
if [ "${VERSION}" = "latest" ]; then
DOWNLOAD_URL=$(curl -sSf https://api.github.com/repos/summerwind/gh-app-auth/releases/latest|jq -r '.assets[].browser_download_url|select(match("linux.amd64."))')
curl -sSfL -o gh-app-auth.tar.gz ${DOWNLOAD_URL}
else
curl -sSfL -o gh-app-auth.tar.gz https://github.com/summerwind/gh-app-auth/releases/download/v${VERSION}/gh-app-auth_${VERSION}_linux_amd64.tar.gz
fi
tar xzvf gh-app-auth.tar.gz
sudo install gh-app-auth /usr/local/bin/gh-app-auth
- id: auth
shell: bash
run: |
set -e
echo "${{ inputs.private-key }}" > /tmp/gh-app-private-key.pem
TOKEN=$(/usr/local/bin/gh-app-auth --app-id "${{ inputs.app-id }}" --private-key "/tmp/gh-app-private-key.pem" --account "${{ inputs.account }}")
echo "::add-mask::$TOKEN"
echo "token=$TOKEN" >> $GITHUB_OUTPUT