diff --git a/__tests__/github.test.ts b/__tests__/github.test.ts index f992db1..c065cca 100644 --- a/__tests__/github.test.ts +++ b/__tests__/github.test.ts @@ -138,7 +138,7 @@ describe('printActionsRuntimeTokenACs', () => { }); it('malformed', async () => { process.env.ACTIONS_RUNTIME_TOKEN = 'foo'; - await expect(GitHub.printActionsRuntimeTokenACs()).rejects.toThrow(new Error("Cannot parse GitHub Actions Runtime Token: Invalid token specified: Cannot read properties of undefined (reading 'replace')")); + await expect(GitHub.printActionsRuntimeTokenACs()).rejects.toThrow(new Error('Cannot parse GitHub Actions Runtime Token: Invalid token specified: missing part #2')); }); it('refs/heads/master', async () => { const infoSpy = jest.spyOn(core, 'info'); diff --git a/src/github.ts b/src/github.ts index e7b8e1c..d49f0ac 100644 --- a/src/github.ts +++ b/src/github.ts @@ -18,7 +18,7 @@ import {GitHub as Octokit} from '@actions/github/lib/utils'; import * as core from '@actions/core'; import * as github from '@actions/github'; import {Context} from '@actions/github/lib/context'; -import jwt_decode from 'jwt-decode'; +import {jwtDecode, JwtPayload} from 'jwt-decode'; import {GitHubActionsRuntimeToken, GitHubActionsRuntimeTokenAC, GitHubRepo} from './types/github'; @@ -51,7 +51,7 @@ export class GitHub { static get actionsRuntimeToken(): GitHubActionsRuntimeToken | undefined { const token = process.env['ACTIONS_RUNTIME_TOKEN'] || ''; - return token ? jwt_decode(token) : undefined; + return token ? (jwtDecode(token) as GitHubActionsRuntimeToken) : undefined; } public static async printActionsRuntimeTokenACs() {