-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acd131d
commit 6fd5d8d
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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: latest | ||
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 -sS https://api.github.com/repos/summerwind/gh-app-auth/releases/latest|jq -r '.assets[].browser_download_url|select(match("linux.amd64."))') | ||
else | ||
DOWNLOAD_URL=$(curl -sS https://api.github.com/repos/summerwind/gh-app-auth/releases/tags/${VERSION}|jq -r '.assets[].browser_download_url|select(match("linux.amd64."))') | ||
fi | ||
curl -sfL -o gh-app-auth.tar.gz ${DOWNLOAD_URL} | ||
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 "::set-output name=token::$TOKEN" |