github(summary): use relative path for artifact link
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
1
.github/workflows/test.yml
vendored
1
.github/workflows/test.yml
vendored
@@ -149,6 +149,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
CTN_BUILDER_NAME: ${{ steps.builder.outputs.name }}
|
CTN_BUILDER_NAME: ${{ steps.builder.outputs.name }}
|
||||||
|
TEST_FOR_SUMMARY: ${{ secrets.TEST_FOR_SUMMARY }}
|
||||||
-
|
-
|
||||||
name: Check coverage
|
name: Check coverage
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -68,10 +68,18 @@ export class GitHub {
|
|||||||
return `${github.context.repo.owner}/${github.context.repo.repo}`;
|
return `${github.context.repo.owner}/${github.context.repo.repo}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static workflowRunURL(setAttempts?: boolean): string {
|
static get runId(): number {
|
||||||
|
return process.env.GITHUB_RUN_ID ? +process.env.GITHUB_RUN_ID : github.context.runId;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get runAttempt(): number {
|
||||||
// TODO: runAttempt is not yet part of github.context but will be in a
|
// TODO: runAttempt is not yet part of github.context but will be in a
|
||||||
// future release of @actions/github package: https://github.com/actions/toolkit/commit/faa425440f86f9c16587a19dfb59491253a2c92a
|
// future release of @actions/github package: https://github.com/actions/toolkit/commit/faa425440f86f9c16587a19dfb59491253a2c92a
|
||||||
return `${GitHub.serverURL}/${GitHub.repository}/actions/runs/${github.context.runId}${setAttempts ? `/attempts/${process.env.GITHUB_RUN_ATTEMPT || 1}` : ''}`;
|
return process.env.GITHUB_RUN_ATTEMPT ? +process.env.GITHUB_RUN_ATTEMPT : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static workflowRunURL(setAttempts?: boolean): string {
|
||||||
|
return `${GitHub.serverURL}/${GitHub.repository}/actions/runs/${GitHub.runId}${setAttempts ? `/attempts/${GitHub.runAttempt}` : ''}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get actionsRuntimeToken(): GitHubActionsRuntimeToken | undefined {
|
static get actionsRuntimeToken(): GitHubActionsRuntimeToken | undefined {
|
||||||
@@ -211,6 +219,14 @@ export class GitHub {
|
|||||||
|
|
||||||
const refsSize = Object.keys(opts.exportRes.refs).length;
|
const refsSize = Object.keys(opts.exportRes.refs).length;
|
||||||
|
|
||||||
|
// we just need the last two parts of the URL as they are always relative
|
||||||
|
// to the workflow run URL otherwise URL could be broken if GitHub
|
||||||
|
// repository name is part of a secret value used in the workflow. e.g.:
|
||||||
|
// artifact: https://github.com/docker/actions-toolkit/actions/runs/9552208295/artifacts/1609622746
|
||||||
|
// workflow: https://github.com/docker/actions-toolkit/actions/runs/9552208295
|
||||||
|
// https://github.com/docker/actions-toolkit/issues/367
|
||||||
|
const artifactRelativeURL = `./${GitHub.runId}/${opts.uploadRes.url.split('/').slice(-2).join('/')}`;
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
const sum = core.summary
|
const sum = core.summary
|
||||||
.addHeading('Docker Build summary', 1)
|
.addHeading('Docker Build summary', 1)
|
||||||
@@ -221,7 +237,7 @@ export class GitHub {
|
|||||||
.addRaw(addLink('Learn more', 'https://docs.docker.com/go/build-summary/'))
|
.addRaw(addLink('Learn more', 'https://docs.docker.com/go/build-summary/'))
|
||||||
.addRaw('</p>')
|
.addRaw('</p>')
|
||||||
.addRaw(`<p>`)
|
.addRaw(`<p>`)
|
||||||
.addRaw(`:arrow_down: ${addLink(`<strong>${opts.uploadRes.filename}</strong>`, opts.uploadRes.url)} (${Util.formatFileSize(opts.uploadRes.size)})`)
|
.addRaw(`:arrow_down: ${addLink(`<strong>${opts.uploadRes.filename}</strong>`, artifactRelativeURL)} (${Util.formatFileSize(opts.uploadRes.size)})`)
|
||||||
.addBreak()
|
.addBreak()
|
||||||
.addRaw(`This file includes <strong>${refsSize} build record${refsSize > 1 ? 's' : ''}</strong>.`)
|
.addRaw(`This file includes <strong>${refsSize} build record${refsSize > 1 ? 's' : ''}</strong>.`)
|
||||||
.addRaw(`</p>`)
|
.addRaw(`</p>`)
|
||||||
|
|||||||
Reference in New Issue
Block a user