-
Notifications
You must be signed in to change notification settings - Fork 30
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
7 changed files
with
644 additions
and
472 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import * as core from '@actions/core'; | ||
import * as io from '@actions/io'; | ||
import * as exec from '@actions/exec'; | ||
|
||
export class GithubActionsToolHelper { | ||
|
||
public getGithubRunId(): string { | ||
return process.env['GITHUB_RUN_ID'] || ''; | ||
} | ||
|
||
public getGithubRunNumber(): string { | ||
return process.env['GITHUB_RUN_NUMBER'] || ''; | ||
} | ||
|
||
public info(message: string): void { | ||
core.info(message); | ||
} | ||
|
||
public error(message: string): void { | ||
core.error(message); | ||
} | ||
|
||
public warning(message: string): void { | ||
core.warning(message); | ||
} | ||
|
||
public debug(message: string): void { | ||
core.debug(message); | ||
} | ||
|
||
public async exec(commandLine: string, args?: string[], execOptions?: exec.ExecOptions): Promise<number> { | ||
return await exec.exec(commandLine, args, execOptions); | ||
} | ||
|
||
public async ExecOptions(): Promise<exec.ExecOptions> { | ||
let stdout = ''; | ||
let stderr = ''; | ||
|
||
const options: exec.ExecOptions = { | ||
listeners: { | ||
stdout: (data: Buffer) => { | ||
stdout += data.toString(); | ||
}, | ||
stderr: (data: Buffer) => { | ||
stderr += data.toString(); | ||
}, | ||
}, | ||
}; | ||
return options; | ||
} | ||
|
||
public getInput(name: string, options?: core.InputOptions): string { | ||
return core.getInput(name, options); | ||
} | ||
|
||
public setFailed(message: string): void { | ||
core.setFailed(message); | ||
} | ||
|
||
public which(tool: string, check?: boolean): Promise<string> { | ||
return io.which(tool, check); | ||
} | ||
|
||
public getContainerAppName(containerAppName: string): string { | ||
containerAppName = `gh-action-app-${this.getGithubRunId()}-${this.getGithubRunNumber()}`; | ||
// Replace all '.' characters with '-' characters in the Container App name | ||
containerAppName = containerAppName.replace(/\./gi, "-"); | ||
this.info(`Default Container App name: ${containerAppName}`); | ||
return containerAppName | ||
} | ||
|
||
public getTelemetryArg(): string { | ||
return `CALLER_ID=github-actions-v1`; | ||
} | ||
} |
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