forked from tibdex/github-app-token
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Duplicate of tibdex#14 to make some adjustments. Co-authored-by: adoami <[email protected]> Co-authored-by: edulop <[email protected]>
- Loading branch information
1 parent
0c895ba
commit d196e95
Showing
6 changed files
with
401 additions
and
306 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 |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Publish | |
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
|
||
jobs: | ||
publish: | ||
|
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Test | |
on: | ||
push: | ||
branches-ignore: | ||
- master | ||
- main | ||
|
||
jobs: | ||
test: | ||
|
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
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,16 @@ | ||
import { context, getOctokit } from "@actions/github"; | ||
import { createAppAuth } from "@octokit/auth-app"; | ||
|
||
export const fetchInstallationToken = async ({ | ||
appId, | ||
privateKey, | ||
}: Readonly<{ appId: string; privateKey: string }>): Promise<string> => { | ||
const app = createAppAuth({ appId, privateKey }); | ||
const authApp = await app({ type: "app" }); | ||
const octokit = getOctokit(authApp.token); | ||
const { | ||
data: { id: installationId }, | ||
} = await octokit.apps.getRepoInstallation(context.repo); | ||
const installation = await app({ installationId, type: "installation" }); | ||
return installation.token; | ||
}; |
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
Oops, something went wrong.