mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
Merge pull request #346 from crazy-max/gh-workflow-run-retries
github: set attempts to workflowRunURL
This commit is contained in:
commit
2941f52b66
@ -22,7 +22,8 @@ export const context = {
|
|||||||
repo: 'actions-toolkit'
|
repo: 'actions-toolkit'
|
||||||
},
|
},
|
||||||
ref: 'refs/heads/master',
|
ref: 'refs/heads/master',
|
||||||
runId: 123,
|
runId: 2188748038,
|
||||||
|
runNumber: 15,
|
||||||
payload: {
|
payload: {
|
||||||
after: '860c1904a1ce19322e91ac35af1ab07466440c37',
|
after: '860c1904a1ce19322e91ac35af1ab07466440c37',
|
||||||
base_ref: null,
|
base_ref: null,
|
||||||
|
@ -100,7 +100,7 @@ describe('getProvenanceInput', () => {
|
|||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'true',
|
'true',
|
||||||
'builder-id=https://github.com/docker/actions-toolkit/actions/runs/123'
|
'builder-id=https://github.com/docker/actions-toolkit/actions/runs/2188748038/attempts/2'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'false',
|
'false',
|
||||||
@ -108,11 +108,11 @@ describe('getProvenanceInput', () => {
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'mode=min',
|
'mode=min',
|
||||||
'mode=min,builder-id=https://github.com/docker/actions-toolkit/actions/runs/123'
|
'mode=min,builder-id=https://github.com/docker/actions-toolkit/actions/runs/2188748038/attempts/2'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'mode=max',
|
'mode=max',
|
||||||
'mode=max,builder-id=https://github.com/docker/actions-toolkit/actions/runs/123'
|
'mode=max,builder-id=https://github.com/docker/actions-toolkit/actions/runs/2188748038/attempts/2'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'builder-id=foo',
|
'builder-id=foo',
|
||||||
@ -137,11 +137,11 @@ describe('resolveProvenanceAttrs', () => {
|
|||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'mode=min',
|
'mode=min',
|
||||||
'mode=min,builder-id=https://github.com/docker/actions-toolkit/actions/runs/123'
|
'mode=min,builder-id=https://github.com/docker/actions-toolkit/actions/runs/2188748038/attempts/2'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'mode=max',
|
'mode=max',
|
||||||
'mode=max,builder-id=https://github.com/docker/actions-toolkit/actions/runs/123'
|
'mode=max,builder-id=https://github.com/docker/actions-toolkit/actions/runs/2188748038/attempts/2'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'builder-id=foo',
|
'builder-id=foo',
|
||||||
@ -153,7 +153,7 @@ describe('resolveProvenanceAttrs', () => {
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'',
|
'',
|
||||||
'builder-id=https://github.com/docker/actions-toolkit/actions/runs/123'
|
'builder-id=https://github.com/docker/actions-toolkit/actions/runs/2188748038/attempts/2'
|
||||||
],
|
],
|
||||||
])('given %p', async (input: string, expected: string) => {
|
])('given %p', async (input: string, expected: string) => {
|
||||||
expect(Build.resolveProvenanceAttrs(input)).toEqual(expected);
|
expect(Build.resolveProvenanceAttrs(input)).toEqual(expected);
|
||||||
|
@ -90,8 +90,8 @@ describe('apiURL', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('workflowRunURL', () => {
|
describe('workflowRunURL', () => {
|
||||||
it('returns 123', async () => {
|
it('returns 2188748038', async () => {
|
||||||
expect(GitHub.workflowRunURL).toEqual('https://github.com/docker/actions-toolkit/actions/runs/123');
|
expect(GitHub.workflowRunURL).toEqual('https://github.com/docker/actions-toolkit/actions/runs/2188748038/attempts/2');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -23,6 +23,9 @@ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-'))
|
|||||||
process.env = Object.assign({}, process.env, {
|
process.env = Object.assign({}, process.env, {
|
||||||
TEMP: tmpDir,
|
TEMP: tmpDir,
|
||||||
GITHUB_REPOSITORY: 'docker/actions-toolkit',
|
GITHUB_REPOSITORY: 'docker/actions-toolkit',
|
||||||
|
GITHUB_RUN_ATTEMPT: 2,
|
||||||
|
GITHUB_RUN_ID: 2188748038,
|
||||||
|
GITHUB_RUN_NUMBER: 15,
|
||||||
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
||||||
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
||||||
}) as {
|
}) as {
|
||||||
|
@ -23,6 +23,9 @@ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-'))
|
|||||||
process.env = Object.assign({}, process.env, {
|
process.env = Object.assign({}, process.env, {
|
||||||
TEMP: tmpDir,
|
TEMP: tmpDir,
|
||||||
GITHUB_REPOSITORY: 'docker/actions-toolkit',
|
GITHUB_REPOSITORY: 'docker/actions-toolkit',
|
||||||
|
GITHUB_RUN_ATTEMPT: 2,
|
||||||
|
GITHUB_RUN_ID: 2188748038,
|
||||||
|
GITHUB_RUN_NUMBER: 15,
|
||||||
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
||||||
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
||||||
}) as {
|
}) as {
|
||||||
|
@ -65,7 +65,9 @@ export class GitHub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static get workflowRunURL(): string {
|
static get workflowRunURL(): string {
|
||||||
return `${GitHub.serverURL}/${github.context.repo.owner}/${github.context.repo.repo}/actions/runs/${github.context.runId}`;
|
const runID = process.env.GITHUB_RUN_ID || github.context.runId;
|
||||||
|
const runAttempt = process.env.GITHUB_RUN_ATTEMPT || 1;
|
||||||
|
return `${GitHub.serverURL}/${github.context.repo.owner}/${github.context.repo.repo}/actions/runs/${runID}/attempts/${runAttempt}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get actionsRuntimeToken(): GitHubActionsRuntimeToken | undefined {
|
static get actionsRuntimeToken(): GitHubActionsRuntimeToken | undefined {
|
||||||
|
Loading…
Reference in New Issue
Block a user