Skip to content

Commit 794528c

Browse files
committed
wip
1 parent 85629ae commit 794528c

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"bugs": {
1313
"url": "https://github.com/actions/typescript-action/issues"
1414
},
15+
"type": "module",
1516
"keywords": [
1617
"actions",
1718
"node",
@@ -43,7 +44,8 @@
4344
"testEnvironment": "node",
4445
"moduleFileExtensions": [
4546
"js",
46-
"ts"
47+
"ts",
48+
"mts"
4749
],
4850
"testMatch": [
4951
"**/*.test.ts"
@@ -53,7 +55,7 @@
5355
"/dist/"
5456
],
5557
"transform": {
56-
"^.+\\.ts$": "ts-jest"
58+
"^.+\\.ts$": ["ts-jest", { "allowImportingTsExtensions": true }]
5759
},
5860
"coverageReporters": [
5961
"json-summary",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* The entrypoint for the action.
33
*/
4-
import { run } from './main'
4+
import { run } from './main.js'
55

66
// eslint-disable-next-line @typescript-eslint/no-floating-promises
77
run()

src/main.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function parse_additional_parameters(
3434
return result
3535
}
3636

37-
async function getGithubTokenViaGithubApp(appId: string, privateKey: string, organization: string, repository: string): Promise<any> {
37+
async function getGithubTokenViaGithubApp(appId: string, privateKey: string, organization: string, repository: string): Promise<string> {
3838
const app = new App({ appId, privateKey });
3939

4040
const { data: installation } = await app.octokit.request(
@@ -43,12 +43,16 @@ async function getGithubTokenViaGithubApp(appId: string, privateKey: string, org
4343

4444
const octokitInstance = await app.getInstallationOctokit(installation.id);
4545

46-
const { token } = await octokitInstance.auth({
46+
const auth = await octokitInstance.auth({
4747
type: 'installation',
4848
installationId: installation.id
49-
}) as any;
49+
});
5050

51-
return token;
51+
if (auth != null && typeof auth === "object" && "token" in auth && typeof auth.token === "string") {
52+
return auth.token;
53+
} else {
54+
throw new Error("Failed to get token");
55+
}
5256
}
5357

5458
/**

0 commit comments

Comments
 (0)