2020-10-25 01:25:23 +00:00
|
|
|
import * as fs from 'fs';
|
|
|
|
import * as path from 'path';
|
|
|
|
import * as dotenv from 'dotenv';
|
2020-10-25 14:13:43 +00:00
|
|
|
import * as moment from 'moment';
|
|
|
|
import {getInputs, Inputs} from '../src/context';
|
2020-10-25 01:25:23 +00:00
|
|
|
import * as github from '../src/github';
|
|
|
|
import {Meta} from '../src/meta';
|
|
|
|
import {Context} from '@actions/github/lib/context';
|
|
|
|
import {ReposGetResponseData} from '@octokit/types';
|
|
|
|
|
|
|
|
jest.spyOn(github, 'repo').mockImplementation(
|
|
|
|
(): Promise<ReposGetResponseData> => {
|
|
|
|
return <Promise<ReposGetResponseData>>require(path.join(__dirname, 'fixtures', 'repo.json'));
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
jest.spyOn(github, 'context').mockImplementation(
|
|
|
|
(): Context => {
|
|
|
|
return new Context();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
jest.spyOn(global.Date.prototype, 'toISOString').mockImplementation(() => {
|
|
|
|
return '2020-01-10T00:30:00.000Z';
|
|
|
|
});
|
|
|
|
|
2020-10-25 14:13:43 +00:00
|
|
|
jest.mock('moment', () => {
|
|
|
|
return () => jest.requireActual('moment')('2020-01-10T00:30:00.000Z');
|
|
|
|
});
|
|
|
|
|
2020-10-25 01:25:23 +00:00
|
|
|
describe('tags and labels', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
Object.keys(process.env).forEach(function (key) {
|
|
|
|
if (key !== 'GITHUB_TOKEN' && key.startsWith('GITHUB_')) {
|
|
|
|
delete process.env[key];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// prettier-ignore
|
|
|
|
test.each([
|
|
|
|
[
|
|
|
|
'event_null.env',
|
|
|
|
{
|
|
|
|
images: ['user/app'],
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
undefined,
|
2020-10-25 01:25:23 +00:00
|
|
|
[],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_empty.env',
|
|
|
|
{
|
|
|
|
images: ['user/app'],
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
undefined,
|
2020-10-25 01:25:23 +00:00
|
|
|
[],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_pull_request.env',
|
|
|
|
{
|
|
|
|
images: ['user/app'],
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'pr-2',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'user/app:pr-2'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=pr-2",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=1e9249f05bfc090e0688b8fb9c1b347586add504",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_push.env',
|
|
|
|
{
|
|
|
|
images: ['user/app'],
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'dev',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'user/app:dev'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=dev",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_push_defbranch.env',
|
|
|
|
{
|
|
|
|
images: ['user/app'],
|
2020-10-25 14:32:14 +00:00
|
|
|
tagEdge: true,
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'edge',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'user/app:edge'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=edge",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
2020-10-25 14:32:14 +00:00
|
|
|
[
|
|
|
|
'event_push_defbranch.env',
|
|
|
|
{
|
|
|
|
images: ['user/app'],
|
|
|
|
} as Inputs,
|
|
|
|
'master',
|
|
|
|
[
|
|
|
|
'user/app:master'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=master",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'event_release.env',
|
|
|
|
{
|
|
|
|
images: ['user/app'],
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'1.1.1',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'user/app:1.1.1',
|
|
|
|
'user/app:latest'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=1.1.1",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_schedule.env',
|
|
|
|
{
|
|
|
|
images: ['user/app'],
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'nightly',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'user/app:nightly'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=nightly",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
2020-10-25 14:13:43 +00:00
|
|
|
[
|
|
|
|
'event_schedule.env',
|
|
|
|
{
|
|
|
|
images: ['user/app'],
|
|
|
|
tagSchedule: `{{date 'YYYYMMDD'}}`
|
|
|
|
} as Inputs,
|
|
|
|
'20200110',
|
|
|
|
[
|
|
|
|
'user/app:20200110'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=20200110",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_schedule.env',
|
|
|
|
{
|
|
|
|
images: ['user/app'],
|
|
|
|
tagSchedule: `{{date 'YYYYMMDD-HHmmss'}}`
|
|
|
|
} as Inputs,
|
|
|
|
'20200110-003000',
|
|
|
|
[
|
|
|
|
'user/app:20200110-003000'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=20200110-003000",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'event_tag.env',
|
|
|
|
{
|
|
|
|
images: ['user/app'],
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'release1',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'user/app:release1'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=release1",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_tag_semver.env',
|
|
|
|
{
|
|
|
|
images: ['user/app'],
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'1.1.1',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'user/app:1.1.1',
|
|
|
|
'user/app:latest'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=1.1.1",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_workflow_dispatch.env',
|
|
|
|
{
|
|
|
|
images: ['user/app'],
|
2020-10-25 14:32:14 +00:00
|
|
|
tagEdge: true,
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'edge',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'user/app:edge'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=edge",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_pull_request.env',
|
|
|
|
{
|
|
|
|
images: ['org/app', 'ghcr.io/user/app'],
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'pr-2',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'org/app:pr-2',
|
|
|
|
'ghcr.io/user/app:pr-2'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=pr-2",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=1e9249f05bfc090e0688b8fb9c1b347586add504",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_push.env',
|
|
|
|
{
|
|
|
|
images: ['org/app', 'ghcr.io/user/app'],
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'dev',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'org/app:dev',
|
|
|
|
'ghcr.io/user/app:dev'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=dev",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_push_defbranch.env',
|
|
|
|
{
|
|
|
|
images: ['org/app', 'ghcr.io/user/app'],
|
2020-10-25 14:32:14 +00:00
|
|
|
tagEdge: true,
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'edge',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'org/app:edge',
|
|
|
|
'ghcr.io/user/app:edge'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=edge",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_schedule.env',
|
|
|
|
{
|
|
|
|
images: ['org/app', 'ghcr.io/user/app'],
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'nightly',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'org/app:nightly',
|
|
|
|
'ghcr.io/user/app:nightly'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=nightly",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_tag_semver.env',
|
|
|
|
{
|
|
|
|
images: ['org/app', 'ghcr.io/user/app'],
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'1.1.1',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'org/app:1.1.1',
|
|
|
|
'org/app:latest',
|
|
|
|
'ghcr.io/user/app:1.1.1',
|
|
|
|
'ghcr.io/user/app:latest'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=1.1.1",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_pull_request.env',
|
|
|
|
{
|
|
|
|
images: ['org/app', 'ghcr.io/user/app'],
|
|
|
|
tagSha: true,
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'pr-2',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'org/app:pr-2',
|
|
|
|
'org/app:sha-1e9249f',
|
|
|
|
'ghcr.io/user/app:pr-2',
|
|
|
|
'ghcr.io/user/app:sha-1e9249f'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=pr-2",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=1e9249f05bfc090e0688b8fb9c1b347586add504",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_push.env',
|
|
|
|
{
|
|
|
|
images: ['org/app', 'ghcr.io/user/app'],
|
|
|
|
tagSha: true,
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'dev',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'org/app:dev',
|
|
|
|
'org/app:sha-90dd603',
|
|
|
|
'ghcr.io/user/app:dev',
|
|
|
|
'ghcr.io/user/app:sha-90dd603'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=dev",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_push_defbranch.env',
|
|
|
|
{
|
|
|
|
images: ['org/app', 'ghcr.io/user/app'],
|
|
|
|
tagSha: true,
|
2020-10-25 14:32:14 +00:00
|
|
|
tagEdge: true,
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'edge',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'org/app:edge',
|
|
|
|
'org/app:sha-90dd603',
|
|
|
|
'ghcr.io/user/app:edge',
|
|
|
|
'ghcr.io/user/app:sha-90dd603'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=edge",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_schedule.env',
|
|
|
|
{
|
|
|
|
images: ['org/app', 'ghcr.io/user/app'],
|
|
|
|
tagSha: true,
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'nightly',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'org/app:nightly',
|
|
|
|
'org/app:sha-90dd603',
|
|
|
|
'ghcr.io/user/app:nightly',
|
|
|
|
'ghcr.io/user/app:sha-90dd603'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=nightly",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_tag_semver.env',
|
|
|
|
{
|
|
|
|
images: ['org/app', 'ghcr.io/user/app'],
|
|
|
|
tagSha: true,
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'1.1.1',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'org/app:1.1.1',
|
|
|
|
'org/app:latest',
|
|
|
|
'org/app:sha-90dd603',
|
|
|
|
'ghcr.io/user/app:1.1.1',
|
|
|
|
'ghcr.io/user/app:latest',
|
|
|
|
'ghcr.io/user/app:sha-90dd603'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=1.1.1",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_push.env',
|
|
|
|
{
|
|
|
|
images: ['org/app', 'ghcr.io/user/app'],
|
|
|
|
tagSha: true,
|
2020-10-25 14:32:14 +00:00
|
|
|
tagEdge: true,
|
|
|
|
tagEdgeBranch: 'dev'
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'edge',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'org/app:edge',
|
|
|
|
'org/app:sha-90dd603',
|
|
|
|
'ghcr.io/user/app:edge',
|
|
|
|
'ghcr.io/user/app:sha-90dd603'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=edge",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event_push_defbranch.env',
|
|
|
|
{
|
|
|
|
images: ['org/app', 'ghcr.io/user/app'],
|
|
|
|
tagSha: true,
|
2020-10-25 14:32:14 +00:00
|
|
|
tagEdge: true,
|
|
|
|
tagEdgeBranch: 'dev'
|
2020-10-25 14:13:43 +00:00
|
|
|
} as Inputs,
|
2020-10-25 01:40:42 +00:00
|
|
|
'master',
|
2020-10-25 01:25:23 +00:00
|
|
|
[
|
|
|
|
'org/app:master',
|
|
|
|
'org/app:sha-90dd603',
|
|
|
|
'ghcr.io/user/app:master',
|
|
|
|
'ghcr.io/user/app:sha-90dd603'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"org.opencontainers.image.title=Hello-World",
|
|
|
|
"org.opencontainers.image.description=This your first repo!",
|
|
|
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
|
|
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
|
|
|
"org.opencontainers.image.version=master",
|
|
|
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
|
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
|
|
"org.opencontainers.image.licenses=MIT"
|
|
|
|
]
|
|
|
|
],
|
2020-10-25 01:40:42 +00:00
|
|
|
])('given %p event ', async (envFile, inputs, exVersion, exTags, exLabels) => {
|
2020-10-25 01:25:23 +00:00
|
|
|
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
|
|
|
const context = github.context();
|
2020-10-25 14:13:43 +00:00
|
|
|
console.log(process.env, context);
|
2020-10-25 01:25:23 +00:00
|
|
|
|
|
|
|
const repo = await github.repo(process.env.GITHUB_TOKEN || '');
|
2020-10-25 14:13:43 +00:00
|
|
|
const meta = new Meta({...getInputs(), ...inputs}, context, repo);
|
2020-10-25 01:25:23 +00:00
|
|
|
|
2020-10-25 01:40:42 +00:00
|
|
|
const version = meta.version();
|
2020-10-25 14:13:43 +00:00
|
|
|
console.log('version', version);
|
2020-10-25 01:40:42 +00:00
|
|
|
expect(version).toEqual(exVersion);
|
|
|
|
|
2020-10-25 01:25:23 +00:00
|
|
|
const tags = meta.tags();
|
2020-10-25 14:13:43 +00:00
|
|
|
console.log('tags', tags);
|
2020-10-25 01:25:23 +00:00
|
|
|
expect(tags).toEqual(exTags);
|
|
|
|
|
|
|
|
const labels = meta.labels();
|
2020-10-25 14:13:43 +00:00
|
|
|
console.log('labels', labels);
|
2020-10-25 01:25:23 +00:00
|
|
|
expect(labels).toEqual(exLabels);
|
|
|
|
});
|
|
|
|
});
|