Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add base url as parameter #6

Merged
merged 3 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ By providing some key information to this action, it will return you your GitHub

## Input

| Key | Type | Required | Description |
| ----------------------- | :------: | :------: | ----------------------------------------------------------------------- |
| `appId` | `int` | Yes | Your GitHub App's id |
| `installationId` | `int` | Yes | The installation id of the the GitHub App in this repo / org |
| `privateKey` | `string` | Yes | The private key associated to the GitHub App (typically an RSA private key)|
| Key | Type | Required | Description |
| ---------------- | :------: | :------: | --------------------------------------------------------------------------------------------------------------------------- |
| `appId` | `int` | Yes | Your GitHub App's id |
| `installationId` | `int` | Yes | The installation id of the the GitHub App in this repo / org |
| `privateKey` | `string` | Yes | The private key associated to the GitHub App (typically an RSA private key) |
| `baseUrl` | `string` | No | Custom base url of Github if for example self hosted in enterprise context. For example: `https://github.domain.com/api/v3` |

**Be sure to store your `privateKey` [as a secret](https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) in GitHub Actions!**

## Output

This action returns the relevant installation token for use in subsequent steps, like [actions/github-script](https://github.com/actions/github-script)

| Property | Type | Description |
| ----------------- | --------- | ----------------------------------------------------------------------------------- |
| `token` | `string` | A GitHub App [installation access token](https://docs.github.com/en/rest/reference/apps#create-an-installation-access-token-for-an-app)|
| Property | Type | Description |
| -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `token` | `string` | A GitHub App [installation access token](https://docs.github.com/en/rest/reference/apps#create-an-installation-access-token-for-an-app) |

## Examples

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ inputs:
privateKey:
description: The private key used to sign the JWT
required: true
baseUrl:
description: Optional base url for github requests
required: false
outputs:
token:
description: The generated RS256-signed JWT
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ export async function run(): Promise<void> {
const appId = parseInt(getInput('appId'), 10)
const installationId = parseInt(getInput('installationId'), 10)
const privateKey = getInput('privateKey')
const baseUrl = getInput('baseUrl', {required: false})

const {token} = await getToken({appId, installationId, privateKey})
const {token} = await getToken({appId, installationId, privateKey, baseUrl})

setOutput('token', token)
} catch (error) {
Expand Down