-
Notifications
You must be signed in to change notification settings - Fork 143
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
Showing
10 changed files
with
1,066 additions
and
636 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
The MIT License (MIT) | ||
Copyright (c) 2022 Thibault Derousseaux <[email protected]> | ||
Copyright (c) 2023 Thibault Derousseaux <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
|
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
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
importOrder: ["^node:(.*)$", "<THIRD_PARTY_MODULES>", "^[./]"], | ||
importOrderGroupNamespaceSpecifiers: true, | ||
importOrderSeparation: true, | ||
importOrderSortSpecifiers: true, | ||
trailingComma: "all", | ||
}; |
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 |
---|---|---|
@@ -1,51 +1,49 @@ | ||
import { Buffer } from "node:buffer"; | ||
|
||
import { getInput, info, setFailed, setOutput, setSecret } from "@actions/core"; | ||
import ensureError from "ensure-error"; | ||
import isBase64 from "is-base64"; | ||
|
||
import { fetchInstallationToken } from "./fetch-installation-token.js"; | ||
|
||
const run = async () => { | ||
try { | ||
const appId = getInput("app_id", { required: true }); | ||
|
||
const installationIdInput = getInput("installation_id"); | ||
const installationId = installationIdInput | ||
? Number(installationIdInput) | ||
: undefined; | ||
|
||
const permissionsInput = getInput("permissions"); | ||
const permissions = permissionsInput | ||
? (JSON.parse(permissionsInput) as Record<string, string>) | ||
: undefined; | ||
|
||
const privateKeyInput = getInput("private_key", { required: true }); | ||
const privateKey = isBase64(privateKeyInput) | ||
? Buffer.from(privateKeyInput, "base64").toString("utf8") | ||
: privateKeyInput; | ||
|
||
const repositoryInput = getInput("repository", { required: true }); | ||
const [owner, repo] = repositoryInput.split("/"); | ||
|
||
const githubApiUrlInput = getInput("github_api_url", { required: true }); | ||
const githubApiUrl = new URL(githubApiUrlInput); | ||
|
||
const installationToken = await fetchInstallationToken({ | ||
appId, | ||
githubApiUrl, | ||
installationId, | ||
owner, | ||
permissions, | ||
privateKey, | ||
repo, | ||
}); | ||
|
||
setSecret(installationToken); | ||
setOutput("token", installationToken); | ||
info("Token generated successfully!"); | ||
} catch (_error: unknown) { | ||
const error = ensureError(_error); | ||
setFailed(error); | ||
} | ||
}; | ||
|
||
void run(); | ||
try { | ||
const appId = getInput("app_id", { required: true }); | ||
|
||
const installationIdInput = getInput("installation_id"); | ||
const installationId = installationIdInput | ||
? Number(installationIdInput) | ||
: undefined; | ||
|
||
const permissionsInput = getInput("permissions"); | ||
const permissions = permissionsInput | ||
? (JSON.parse(permissionsInput) as Record<string, string>) | ||
: undefined; | ||
|
||
const privateKeyInput = getInput("private_key", { required: true }); | ||
const privateKey = isBase64(privateKeyInput) | ||
? Buffer.from(privateKeyInput, "base64").toString("utf8") | ||
: privateKeyInput; | ||
|
||
const repositoryInput = getInput("repository", { required: true }); | ||
const [owner, repo] = repositoryInput.split("/"); | ||
|
||
const githubApiUrlInput = getInput("github_api_url", { required: true }); | ||
const githubApiUrl = new URL(githubApiUrlInput); | ||
|
||
const installationToken = await fetchInstallationToken({ | ||
appId, | ||
githubApiUrl, | ||
installationId, | ||
owner, | ||
permissions, | ||
privateKey, | ||
repo, | ||
}); | ||
|
||
setSecret(installationToken); | ||
setOutput("token", installationToken); | ||
info("Token generated successfully!"); | ||
} catch (_error: unknown) { | ||
const error = ensureError(_error); | ||
setFailed(error); | ||
} |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "nodenext", | ||
"moduleResolution": "nodenext", | ||
"module": "Node16", | ||
"moduleResolution": "Node16", | ||
"noEmit": true, | ||
"strict": true, | ||
"target": "es2021", | ||
"types": ["node", "error-cause/auto"] | ||
"target": "ES2022", | ||
"types": ["node"] | ||
}, | ||
"include": ["src"] | ||
} |
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.