Compare commits

..

8 Commits

Author SHA1 Message Date
CrazyMax
4a3aaf409c Update README 2020-10-26 17:58:13 +01:00
CrazyMax
0c4748bf65 Update cron 2020-10-26 17:54:22 +01:00
CrazyMax
ffb794a3fd Update CHANGELOG 2020-10-26 17:53:34 +01:00
CrazyMax
0dac4059e9 Set latest tag only if matches with a pattern 2020-10-26 17:51:00 +01:00
dependabot[bot]
4d7603f754 Bump codecov/codecov-action from v1.0.13 to v1.0.14 (#4)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from v1.0.13 to v1.0.14.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Commits](https://github.com/codecov/codecov-action/compare/v1.0.13...7d5dfa54903bd909319c580a00535b483d1efcf3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-26 11:37:33 +00:00
CrazyMax
06c67913f5 Update README 2020-10-26 01:51:56 +01:00
CrazyMax
1c62cbada4 Update CHANGELOG 2020-10-26 01:44:06 +01:00
CrazyMax
5bc3bf6dce Coerces Git tag to semver (#3)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2020-10-26 00:39:21 +00:00
15 changed files with 1011 additions and 457 deletions

View File

@@ -2,7 +2,7 @@ name: ci
on:
schedule:
- cron: '0 * * * *' # every hours
- cron: '0 */4 * * *' # every 4 hours
push:
branches:
- '**'
@@ -53,6 +53,29 @@ jobs:
tag-sha: true
tag-schedule: ${{ matrix.tag-schedule }}
coerce:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tag-coerce-tag:
- "{{raw}}"
- "{{major}}.{{minor}}"
- "{{patch}}"
steps:
-
name: Checkout
uses: actions/checkout@v2.3.3
-
name: Docker meta
uses: ./
with:
images: |
${{ env.DOCKER_IMAGE }}
ghcr.io/name/app
tag-coerce-tag: ${{ matrix.tag-coerce-tag }}
tag-sha: true
docker-push:
runs-on: ubuntu-latest
services:

View File

@@ -39,7 +39,7 @@ jobs:
run: yarn run test
-
name: Upload coverage
uses: codecov/codecov-action@v1.0.13
uses: codecov/codecov-action@v1.0.14
if: success()
with:
token: ${{ secrets.CODECOV_TOKEN }}

View File

@@ -1,5 +1,13 @@
# Changelog
## 1.3.0 (2020/10/26)
* Set latest tag only if matches with a pattern
## 1.2.0 (2020/10/26)
* Coerces Git tag to semver (#3)
## 1.1.0 (2020/10/25)
* Allow to templatize schedule tag (#1)

View File

@@ -23,7 +23,9 @@ ___
* [inputs](#inputs)
* [outputs](#outputs)
* [Notes](#notes)
* [Templates available for schedule tag](#templates-available-for-schedule-tag)
* [Latest tag](#latest-tag)
* [Coerces Git tag](#coerces-git-tag)
* [Schedule tag](#schedule-tag)
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
* [How can I help?](#how-can-i-help)
* [License](#license)
@@ -37,14 +39,14 @@ ___
## Overview
| Event | Ref | Commit SHA | Docker Tags |
|-----------------|-------------------------------|------------|------------------------------------|
| `schedule` | | `45f132a` | `sha-45f132a`, `nightly` |
| `pull_request` | `refs/pull/2/merge` | `a123b57` | `sha-a123b57`, `pr-2` |
| `push` | `refs/heads/<default_branch>` | `676cae2` | `sha-676cae2`, `edge` |
| `push` | `refs/heads/dev` | `cf20257` | `sha-cf20257`, `dev` |
| `push` | `refs/heads/my/branch` | `a5df687` | `sha-a5df687`, `my-branch` |
| `push tag` | `refs/tags/v1.2.3` | `bf4565b` | `sha-bf4565b`, `1.2.3`, `latest` |
| `push tag` | `refs/tags/mytag` | `afb7833` | `sha-afb7833`, `mytag` |
|-----------------|-------------------------------|------------|-------------------------------------|
| `schedule` | `refs/heads/master` | `45f132a` | `sha-45f132a`, `nightly` |
| `pull_request` | `refs/pull/2/merge` | `a123b57` | `sha-a123b57`, `pr-2` |
| `push` | `refs/heads/<default_branch>` | `676cae2` | `sha-676cae2`, `edge` |
| `push` | `refs/heads/dev` | `cf20257` | `sha-cf20257`, `dev` |
| `push` | `refs/heads/my/branch` | `a5df687` | `sha-a5df687`, `my-branch` |
| `push tag` | `refs/tags/v1.2.3` | `bf4565b` | `sha-bf4565b`, `1.2.3`, `latest` |
| `push tag` | `refs/tags/mytag` | `afb7833` | `sha-afb7833`, `mytag` |
## Usage
@@ -114,7 +116,9 @@ Following inputs can be used as `step.with` keys
| `tag-sha` | Bool | Add git short SHA as Docker tag (default `false`) |
| `tag-edge` | Bool | Enable edge branch tagging (default `false`) |
| `tag-edge-branch` | String | Branch that will be tagged as edge (default `repo.default_branch`) |
| `tag-schedule` | String | [Handlebars template](https://handlebarsjs.com/guide/) to apply to schedule tag (default `nightly`) |
| `tag-coerce-tag` | String | Coerces Git tag to semver if possible using [template](#coerces-git-tag) |
| `tag-latest-match` | String | Set `latest` tag only if [matches with a pattern](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) |
| `tag-schedule` | String | [Template](#schedule-tag) to apply to schedule tag (default `nightly`) |
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
@@ -132,7 +136,30 @@ Following outputs are available
## Notes
### Templates available for schedule tag
### Latest tag
`latest` tag is created with the following conditions:
* Git tag is a valid [semver](https://semver.org/)
* Provided `tag-coerce-tag` is valid
If `tag-latest-match` is filled, then it has priority over the creation of the tag.
### Coerces Git tag
Provides a very forgiving translation of a non-semver tag to semver. For more information see
[Coercion section](https://www.npmjs.com/package/semver#coercion). `tag-coerce-tag` supports
[Handlebars template](https://handlebarsjs.com/guide/) with the following inputs:
| `tag-coerce-tag` | Git tag | Version |
|-------------------------|----------|---------|
| `{{raw}}` | `v1.2.3` | `1.2.3` |
| `{{major}}.{{minor}}` | `v1.2.3` | `1.2` |
| `{{major}}` | `v1.2.3` | `1` |
| `{{minor}}` | `v1.2.3` | `2` |
| `{{patch}}` | `v1.2.3` | `3` |
### Schedule tag
`tag-schedule` is specially crafted input to support [Handlebars template](https://handlebarsjs.com/guide/) with
the following expressions:

View File

@@ -0,0 +1,23 @@
GITHUB_ACTION=crazy-maxghaction-dump-context
GITHUB_ACTIONS=true
GITHUB_ACTION_PATH=/home/runner/work/_actions/crazy-max/ghaction-dump-context/v1
GITHUB_ACTOR=crazy-max
GITHUB_API_URL=https://api.github.com
GITHUB_BASE_REF=
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_6ee180c2-b331-434a-a867-89534cbefd83
GITHUB_EVENT_NAME=push
#GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=
GITHUB_JOB=event
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_6ee180c2-b331-434a-a867-89534cbefd83
GITHUB_REF=refs/tags/20200110-RC2
GITHUB_REPOSITORY=crazy-max/test-docker-action
GITHUB_REPOSITORY_OWNER=crazy-max
GITHUB_RETENTION_DAYS=90
GITHUB_RUN_ID=325968230
GITHUB_RUN_NUMBER=4
GITHUB_SERVER_URL=https://github.com
GITHUB_SHA=90dd6032fac8bda1b6c4436a2e65de27961ed071
GITHUB_WORKFLOW=event
GITHUB_WORKSPACE=/home/runner/work/test-docker-action/test-docker-action

View File

@@ -0,0 +1,23 @@
GITHUB_ACTION=crazy-maxghaction-dump-context
GITHUB_ACTIONS=true
GITHUB_ACTION_PATH=/home/runner/work/_actions/crazy-max/ghaction-dump-context/v1
GITHUB_ACTOR=crazy-max
GITHUB_API_URL=https://api.github.com
GITHUB_BASE_REF=
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_6ee180c2-b331-434a-a867-89534cbefd83
GITHUB_EVENT_NAME=push
#GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=
GITHUB_JOB=event
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_6ee180c2-b331-434a-a867-89534cbefd83
GITHUB_REF=refs/tags/sometag
GITHUB_REPOSITORY=crazy-max/test-docker-action
GITHUB_REPOSITORY_OWNER=crazy-max
GITHUB_RETENTION_DAYS=90
GITHUB_RUN_ID=325968230
GITHUB_RUN_NUMBER=4
GITHUB_SERVER_URL=https://github.com
GITHUB_SHA=90dd6032fac8bda1b6c4436a2e65de27961ed071
GITHUB_WORKFLOW=event
GITHUB_WORKSPACE=/home/runner/work/test-docker-action/test-docker-action

View File

@@ -0,0 +1,23 @@
GITHUB_ACTION=crazy-maxghaction-dump-context
GITHUB_ACTIONS=true
GITHUB_ACTION_PATH=/home/runner/work/_actions/crazy-max/ghaction-dump-context/v1
GITHUB_ACTOR=crazy-max
GITHUB_API_URL=https://api.github.com
GITHUB_BASE_REF=
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_6ee180c2-b331-434a-a867-89534cbefd83
GITHUB_EVENT_NAME=push
#GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=
GITHUB_JOB=event
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_6ee180c2-b331-434a-a867-89534cbefd83
GITHUB_REF=refs/tags/v2.0.8-beta.67
GITHUB_REPOSITORY=crazy-max/test-docker-action
GITHUB_REPOSITORY_OWNER=crazy-max
GITHUB_RETENTION_DAYS=90
GITHUB_RUN_ID=325968230
GITHUB_RUN_NUMBER=4
GITHUB_SERVER_URL=https://github.com
GITHUB_SHA=90dd6032fac8bda1b6c4436a2e65de27961ed071
GITHUB_WORKFLOW=event
GITHUB_WORKSPACE=/home/runner/work/test-docker-action/test-docker-action

File diff suppressed because it is too large Load Diff

View File

@@ -21,8 +21,14 @@ inputs:
tag-edge-branch:
description: 'Branch that will be tagged as edge (default repo.default_branch)'
required: false
tag-coerce-tag:
description: 'Coerces Git tag to semver if possible using template'
required: false
tag-latest-match:
description: 'Set latest tag only if matches with a pattern'
required: false
tag-schedule:
description: 'Handlebars template to apply to schedule tag'
description: 'Template to apply to schedule tag'
default: 'nightly'
required: false
sep-tags:

121
dist/index.js generated vendored
View File

@@ -25,6 +25,8 @@ function getInputs() {
tagSha: /true/i.test(core.getInput('tag-sha') || 'false'),
tagEdge: /true/i.test(core.getInput('tag-edge') || 'false'),
tagEdgeBranch: core.getInput('tag-edge-branch'),
tagCoerceTag: core.getInput('tag-coerce-tag'),
tagLatestMatch: core.getInput('tag-latest-match'),
tagSchedule: core.getInput('tag-schedule') || 'nightly',
sepTags: core.getInput('sep-tags') || `\n`,
sepLabels: core.getInput('sep-labels') || `\n`,
@@ -129,9 +131,9 @@ function run() {
const meta = new meta_1.Meta(inputs, context, repo);
const version = meta.version();
core.startGroup(`Docker image version`);
core.info(`${version}`);
core.info(version.version || '');
core.endGroup();
core.setOutput('version', version || '');
core.setOutput('version', version.version || '');
const tags = meta.tags();
core.startGroup(`Docker tags`);
for (let tag of tags) {
@@ -167,7 +169,6 @@ exports.Meta = void 0;
const handlebars = __webpack_require__(7492);
const moment = __webpack_require__(9623);
const semver = __webpack_require__(1383);
const core = __webpack_require__(2186);
class Meta {
constructor(inputs, context, repo) {
this.inputs = inputs;
@@ -179,40 +180,69 @@ class Meta {
this.date = new Date();
}
version() {
var _a;
const currentDate = this.date;
const version = {
version: undefined,
latest: false
};
if (/schedule/.test(this.context.eventName)) {
return handlebars.compile(this.inputs.tagSchedule)(this.scheduleTplContext());
version.version = handlebars.compile(this.inputs.tagSchedule)({
date: function (format) {
return moment(currentDate).utc().format(format);
}
});
}
else if (/^refs\/tags\//.test(this.context.ref)) {
const tag = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
const sver = semver.clean(tag);
return sver ? sver : tag;
}
else if (/^refs\/heads\//.test(this.context.ref)) {
const branch = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');
return this.inputs.tagEdge && this.inputs.tagEdgeBranch === branch ? 'edge' : branch;
}
else if (/^refs\/pull\//.test(this.context.ref)) {
const pr = this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '');
return `pr-${pr}`;
}
}
tags() {
let tags = [];
for (const image of this.inputs.images) {
if (/schedule/.test(this.context.eventName)) {
tags.push.apply(tags, this.eventSchedule(image));
if (this.inputs.tagCoerceTag) {
const coerce = semver.coerce(tag);
if (coerce) {
version.version = handlebars.compile(this.inputs.tagCoerceTag)(coerce);
version.latest = true;
}
else if (sver) {
version.version = sver;
version.latest = true;
}
else {
version.version = tag;
}
}
else if (/^refs\/tags\//.test(this.context.ref)) {
tags.push.apply(tags, this.eventTag(image));
}
else if (/^refs\/heads\//.test(this.context.ref)) {
tags.push.apply(tags, this.eventBranch(image));
}
else if (/^refs\/pull\//.test(this.context.ref)) {
tags.push.apply(tags, this.eventPullRequest(image));
else if (sver) {
version.version = sver;
version.latest = true;
}
else {
core.warning(`Unknown event "${this.context.eventName}" with ref "${this.context.ref}"`);
version.version = tag;
}
}
else if (/^refs\/heads\//.test(this.context.ref)) {
version.version = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');
if (this.inputs.tagEdge && this.inputs.tagEdgeBranch === version.version) {
version.version = 'edge';
}
}
else if (/^refs\/pull\//.test(this.context.ref)) {
version.version = `pr-${this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '')}`;
}
if (this.inputs.tagLatestMatch) {
const match = (_a = version.version) === null || _a === void 0 ? void 0 : _a.match(new RegExp(this.inputs.tagLatestMatch));
version.latest = match !== null;
}
return version;
}
tags() {
const version = this.version();
if (!version.version) {
return [];
}
let tags = [];
for (const image of this.inputs.images) {
tags.push(`${image}:${version.version}`);
if (version.latest) {
tags.push(`${image}:latest`);
}
if (this.context.sha && this.inputs.tagSha) {
tags.push(`${image}:sha-${this.context.sha.substr(0, 7)}`);
@@ -227,43 +257,12 @@ class Meta {
`org.opencontainers.image.description=${this.repo.description || ''}`,
`org.opencontainers.image.url=${this.repo.html_url || ''}`,
`org.opencontainers.image.source=${this.repo.clone_url || ''}`,
`org.opencontainers.image.version=${this.version() || ''}`,
`org.opencontainers.image.version=${this.version().version || ''}`,
`org.opencontainers.image.created=${this.date.toISOString()}`,
`org.opencontainers.image.revision=${this.context.sha || ''}`,
`org.opencontainers.image.licenses=${((_a = this.repo.license) === null || _a === void 0 ? void 0 : _a.spdx_id) || ''}`
];
}
eventSchedule(image) {
const schedule = handlebars.compile(this.inputs.tagSchedule)(this.scheduleTplContext());
return [`${image}:${schedule}`];
}
eventTag(image) {
const tag = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
const version = semver.clean(tag);
if (version) {
return [`${image}:${version}`, `${image}:latest`];
}
return [`${image}:${tag}`];
}
eventBranch(image) {
const branch = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');
if (this.inputs.tagEdge && this.inputs.tagEdgeBranch === branch) {
return [`${image}:edge`];
}
return [`${image}:${branch}`];
}
eventPullRequest(image) {
const pr = this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '');
return [`${image}:pr-${pr}`];
}
scheduleTplContext() {
const currentDate = this.date;
return {
date: function (format) {
return moment(currentDate).utc().format(format);
}
};
}
}
exports.Meta = Meta;
//# sourceMappingURL=meta.js.map

View File

@@ -5,6 +5,8 @@ export interface Inputs {
tagSha: boolean;
tagEdge: boolean;
tagEdgeBranch: string;
tagCoerceTag: string;
tagLatestMatch: string;
tagSchedule: string;
sepTags: string;
sepLabels: string;
@@ -17,6 +19,8 @@ export function getInputs(): Inputs {
tagSha: /true/i.test(core.getInput('tag-sha') || 'false'),
tagEdge: /true/i.test(core.getInput('tag-edge') || 'false'),
tagEdgeBranch: core.getInput('tag-edge-branch'),
tagCoerceTag: core.getInput('tag-coerce-tag'),
tagLatestMatch: core.getInput('tag-latest-match'),
tagSchedule: core.getInput('tag-schedule') || 'nightly',
sepTags: core.getInput('sep-tags') || `\n`,
sepLabels: core.getInput('sep-labels') || `\n`,

View File

@@ -1,6 +1,6 @@
import {getInputs, Inputs} from './context';
import * as github from './github';
import {Meta} from './meta';
import {Meta, Version} from './meta';
import * as core from '@actions/core';
import {Context} from '@actions/github/lib/context';
import {ReposGetResponseData} from '@octokit/types';
@@ -27,11 +27,11 @@ async function run() {
const meta: Meta = new Meta(inputs, context, repo);
const version: string | undefined = meta.version();
const version: Version = meta.version();
core.startGroup(`Docker image version`);
core.info(`${version}`);
core.info(version.version || '');
core.endGroup();
core.setOutput('version', version || '');
core.setOutput('version', version.version || '');
const tags: Array<string> = meta.tags();
core.startGroup(`Docker tags`);

View File

@@ -2,10 +2,14 @@ import * as handlebars from 'handlebars';
import * as moment from 'moment';
import * as semver from 'semver';
import {Inputs} from './context';
import * as core from '@actions/core';
import {Context} from '@actions/github/lib/context';
import {ReposGetResponseData} from '@octokit/types';
export interface Version {
version: string | undefined;
latest: boolean;
}
export class Meta {
private readonly inputs: Inputs;
private readonly context: Context;
@@ -22,35 +26,67 @@ export class Meta {
this.date = new Date();
}
public version(): string | undefined {
public version(): Version {
const currentDate = this.date;
const version: Version = {
version: undefined,
latest: false
};
if (/schedule/.test(this.context.eventName)) {
return handlebars.compile(this.inputs.tagSchedule)(this.scheduleTplContext());
version.version = handlebars.compile(this.inputs.tagSchedule)({
date: function (format) {
return moment(currentDate).utc().format(format);
}
});
} else if (/^refs\/tags\//.test(this.context.ref)) {
const tag = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
const sver = semver.clean(tag);
return sver ? sver : tag;
if (this.inputs.tagCoerceTag) {
const coerce = semver.coerce(tag);
if (coerce) {
version.version = handlebars.compile(this.inputs.tagCoerceTag)(coerce);
version.latest = true;
} else if (sver) {
version.version = sver;
version.latest = true;
} else {
version.version = tag;
}
} else if (sver) {
version.version = sver;
version.latest = true;
} else {
version.version = tag;
}
} else if (/^refs\/heads\//.test(this.context.ref)) {
const branch = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');
return this.inputs.tagEdge && this.inputs.tagEdgeBranch === branch ? 'edge' : branch;
version.version = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');
if (this.inputs.tagEdge && this.inputs.tagEdgeBranch === version.version) {
version.version = 'edge';
}
} else if (/^refs\/pull\//.test(this.context.ref)) {
const pr = this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '');
return `pr-${pr}`;
version.version = `pr-${this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '')}`;
}
if (this.inputs.tagLatestMatch) {
const match = version.version?.match(new RegExp(this.inputs.tagLatestMatch));
version.latest = match !== null;
}
return version;
}
public tags(): Array<string> {
const version: Version = this.version();
if (!version.version) {
return [];
}
let tags: Array<string> = [];
for (const image of this.inputs.images) {
if (/schedule/.test(this.context.eventName)) {
tags.push.apply(tags, this.eventSchedule(image));
} else if (/^refs\/tags\//.test(this.context.ref)) {
tags.push.apply(tags, this.eventTag(image));
} else if (/^refs\/heads\//.test(this.context.ref)) {
tags.push.apply(tags, this.eventBranch(image));
} else if (/^refs\/pull\//.test(this.context.ref)) {
tags.push.apply(tags, this.eventPullRequest(image));
} else {
core.warning(`Unknown event "${this.context.eventName}" with ref "${this.context.ref}"`);
tags.push(`${image}:${version.version}`);
if (version.latest) {
tags.push(`${image}:latest`);
}
if (this.context.sha && this.inputs.tagSha) {
tags.push(`${image}:sha-${this.context.sha.substr(0, 7)}`);
@@ -65,46 +101,10 @@ export class Meta {
`org.opencontainers.image.description=${this.repo.description || ''}`,
`org.opencontainers.image.url=${this.repo.html_url || ''}`,
`org.opencontainers.image.source=${this.repo.clone_url || ''}`,
`org.opencontainers.image.version=${this.version() || ''}`,
`org.opencontainers.image.version=${this.version().version || ''}`,
`org.opencontainers.image.created=${this.date.toISOString()}`,
`org.opencontainers.image.revision=${this.context.sha || ''}`,
`org.opencontainers.image.licenses=${this.repo.license?.spdx_id || ''}`
];
}
private eventSchedule(image: string): Array<string> {
const schedule = handlebars.compile(this.inputs.tagSchedule)(this.scheduleTplContext());
return [`${image}:${schedule}`];
}
private eventTag(image: string): Array<string> {
const tag = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
const version = semver.clean(tag);
if (version) {
return [`${image}:${version}`, `${image}:latest`];
}
return [`${image}:${tag}`];
}
private eventBranch(image: string): Array<string> {
const branch = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');
if (this.inputs.tagEdge && this.inputs.tagEdgeBranch === branch) {
return [`${image}:edge`];
}
return [`${image}:${branch}`];
}
private eventPullRequest(image: string): Array<string> {
const pr = this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '');
return [`${image}:pr-${pr}`];
}
private scheduleTplContext(): any {
const currentDate = this.date;
return {
date: function (format) {
return moment(currentDate).utc().format(format);
}
};
}
}