Skip to content

Commit

Permalink
Cancel GitHub token refresh at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
EnviousSwan committed Sep 9, 2024
1 parent 78d74ce commit 8209c4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/action/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ async function run(): Promise<void> {
], inputs.steward.extraJars)
} finally {
await workspace.saveWorkspaceCache()
await workspace.cancelTokenRefresh()
}

if (files.existsSync(workspace.runSummary_md)) {
Expand Down
13 changes: 12 additions & 1 deletion src/modules/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export class Workspace {
readonly askpass_sh: NonEmptyString
readonly runSummary_md: string

private intervalId: NodeJS.Timeout | undefined

constructor(
private readonly logger: Logger,
private readonly files: Files,
Expand Down Expand Up @@ -123,7 +125,7 @@ export class Workspace {
}

await this.writeAskPass(token)
setInterval(async () => {
this.intervalId = setInterval(async () => {
await this.writeAskPass(token)
this.logger.info('✓ GitHub Token refreshed')
}, 1000 * 60 * 50)
Expand Down Expand Up @@ -154,6 +156,15 @@ export class Workspace {
this.files.writeFileSync(this.askpass_sh.value, `#!/bin/sh\n\necho '${token}'`)
}

/**
* Cancels the token refresh if it is currently scheduled.
*/
async cancelTokenRefresh(): Promise<void> {
if (this.intervalId) {
clearInterval(this.intervalId)
}
}

/**
* Gets the first eight characters of the SHA-256 hash value for the
* provided file's contents.
Expand Down

0 comments on commit 8209c4a

Please sign in to comment.