Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancel GitHub token refresh at the end #635

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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