mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
github: make attempts optional in workflowRunURL
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
33d4b448ac
commit
fe58cc26f5
@ -97,7 +97,10 @@ describe('repository', () => {
|
|||||||
|
|
||||||
describe('workflowRunURL', () => {
|
describe('workflowRunURL', () => {
|
||||||
it('returns 2188748038', async () => {
|
it('returns 2188748038', async () => {
|
||||||
expect(GitHub.workflowRunURL).toEqual('https://github.com/docker/actions-toolkit/actions/runs/2188748038/attempts/2');
|
expect(GitHub.workflowRunURL()).toEqual('https://github.com/docker/actions-toolkit/actions/runs/2188748038');
|
||||||
|
});
|
||||||
|
it('returns 2188748038 with attempts 2', async () => {
|
||||||
|
expect(GitHub.workflowRunURL(true)).toEqual('https://github.com/docker/actions-toolkit/actions/runs/2188748038/attempts/2');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ export class Build {
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return core.getBooleanInput(name) ? `builder-id=${GitHub.workflowRunURL}` : 'false';
|
return core.getBooleanInput(name) ? `builder-id=${GitHub.workflowRunURL(true)}` : 'false';
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// not a valid boolean, so we assume it's a string
|
// not a valid boolean, so we assume it's a string
|
||||||
return Build.resolveProvenanceAttrs(input);
|
return Build.resolveProvenanceAttrs(input);
|
||||||
@ -140,7 +140,7 @@ export class Build {
|
|||||||
|
|
||||||
public static resolveProvenanceAttrs(input: string): string {
|
public static resolveProvenanceAttrs(input: string): string {
|
||||||
if (!input) {
|
if (!input) {
|
||||||
return `builder-id=${GitHub.workflowRunURL}`;
|
return `builder-id=${GitHub.workflowRunURL(true)}`;
|
||||||
}
|
}
|
||||||
// parse attributes from input
|
// parse attributes from input
|
||||||
const fields = parse(input, {
|
const fields = parse(input, {
|
||||||
@ -158,7 +158,7 @@ export class Build {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if not add builder-id attribute
|
// if not add builder-id attribute
|
||||||
return `${input},builder-id=${GitHub.workflowRunURL}`;
|
return `${input},builder-id=${GitHub.workflowRunURL(true)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static resolveCacheToAttrs(input: string, githubToken?: string): string {
|
public static resolveCacheToAttrs(input: string, githubToken?: string): string {
|
||||||
|
@ -68,10 +68,10 @@ export class GitHub {
|
|||||||
return `${github.context.repo.owner}/${github.context.repo.repo}`;
|
return `${github.context.repo.owner}/${github.context.repo.repo}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get workflowRunURL(): string {
|
public static workflowRunURL(setAttempts?: boolean): string {
|
||||||
const runID = process.env.GITHUB_RUN_ID || github.context.runId;
|
// TODO: runAttempt is not yet part of github.context but will be in a
|
||||||
const runAttempt = process.env.GITHUB_RUN_ATTEMPT || 1;
|
// future release of @actions/github package: https://github.com/actions/toolkit/commit/faa425440f86f9c16587a19dfb59491253a2c92a
|
||||||
return `${GitHub.serverURL}/${GitHub.repository}/actions/runs/${runID}/attempts/${runAttempt}`;
|
return `${GitHub.serverURL}/${GitHub.repository}/actions/runs/${github.context.runId}${setAttempts ? `/attempts/${process.env.GITHUB_RUN_ATTEMPT || 1}` : ''}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get actionsRuntimeToken(): GitHubActionsRuntimeToken | undefined {
|
static get actionsRuntimeToken(): GitHubActionsRuntimeToken | undefined {
|
||||||
@ -191,7 +191,7 @@ export class GitHub {
|
|||||||
const artifactId = BigInt(finalizeArtifactResp.artifactId);
|
const artifactId = BigInt(finalizeArtifactResp.artifactId);
|
||||||
core.info(`Artifact successfully finalized (${artifactId})`);
|
core.info(`Artifact successfully finalized (${artifactId})`);
|
||||||
|
|
||||||
const artifactURL = `${GitHub.workflowRunURL}/artifacts/${artifactId}`;
|
const artifactURL = `${GitHub.workflowRunURL()}/artifacts/${artifactId}`;
|
||||||
core.info(`Artifact download URL: ${artifactURL}`);
|
core.info(`Artifact download URL: ${artifactURL}`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user