Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
55d3462f05 | ||
|
7040b59aa5 | ||
|
3ae5afe041 | ||
|
b747b8aaa7 | ||
|
585ab8356c | ||
|
9de4428611 | ||
|
4c2760ba7a | ||
|
ef12c77b87 | ||
|
c53f88523a | ||
|
6b4bf4724e | ||
|
d48c7d2917 | ||
|
7cb65aaacb | ||
|
0dca12c226 | ||
|
6f270f37d4 | ||
|
2860e42b1f | ||
|
6a86fe1739 | ||
|
86dc87790d | ||
|
b3281c85e6 | ||
|
9ba75ef142 | ||
|
a017e545d7 | ||
|
8adbcfe00d | ||
|
1c9398a965 | ||
|
9fad2f37d6 | ||
|
7ef05591b5 | ||
|
e8ce48988f | ||
|
009f84cd69 |
38
.github/workflows/ci.yml
vendored
38
.github/workflows/ci.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2.3.3
|
uses: actions/checkout@v2
|
||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -42,7 +42,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2.3.3
|
uses: actions/checkout@v2
|
||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -68,7 +68,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2.3.3
|
uses: actions/checkout@v2
|
||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -80,6 +80,31 @@ jobs:
|
|||||||
tag-match: ${{ matrix.tag-match }}
|
tag-match: ${{ matrix.tag-match }}
|
||||||
tag-match-group: ${{ matrix.tag-match-group }}
|
tag-match-group: ${{ matrix.tag-match-group }}
|
||||||
|
|
||||||
|
tag-semver:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
tag-latest:
|
||||||
|
- 'true'
|
||||||
|
- 'false'
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
${{ env.DOCKER_IMAGE }}
|
||||||
|
ghcr.io/name/app
|
||||||
|
tag-semver: |
|
||||||
|
{{raw}}
|
||||||
|
{{version}}
|
||||||
|
{{major}}.{{minor}}.{{patch}}
|
||||||
|
tag-latest: ${{ matrix.tag-latest }}
|
||||||
|
|
||||||
docker-push:
|
docker-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
services:
|
||||||
@@ -90,7 +115,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2.3.3
|
uses: actions/checkout@v2
|
||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
id: docker_meta
|
id: docker_meta
|
||||||
@@ -98,7 +123,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
images: ${{ env.DOCKER_IMAGE }}
|
images: ${{ env.DOCKER_IMAGE }}
|
||||||
tag-sha: true
|
tag-sha: true
|
||||||
tag-match: '\d{1,3}.\d{1,3}.\d{1,3}'
|
tag-semver: |
|
||||||
|
v{{version}}
|
||||||
|
v{{major}}.{{minor}}
|
||||||
|
v{{major}}
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v1
|
||||||
|
4
.github/workflows/labels.yml
vendored
4
.github/workflows/labels.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2.3.3
|
uses: actions/checkout@v2
|
||||||
-
|
-
|
||||||
name: Run Labeler
|
name: Run Labeler
|
||||||
uses: crazy-max/ghaction-github-labeler@v3.1.0
|
uses: crazy-max/ghaction-github-labeler@v3
|
||||||
|
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2.3.3
|
uses: actions/checkout@v2
|
||||||
-
|
-
|
||||||
name: Validate
|
name: Validate
|
||||||
run: docker buildx bake validate
|
run: docker buildx bake validate
|
||||||
@@ -30,7 +30,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2.3.3
|
uses: actions/checkout@v2
|
||||||
-
|
-
|
||||||
name: Install
|
name: Install
|
||||||
run: yarn install
|
run: yarn install
|
||||||
@@ -39,7 +39,7 @@ jobs:
|
|||||||
run: yarn run test
|
run: yarn run test
|
||||||
-
|
-
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
uses: codecov/codecov-action@v1.0.14
|
uses: codecov/codecov-action@v1
|
||||||
if: success()
|
if: success()
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
36
CHANGELOG.md
36
CHANGELOG.md
@@ -1,5 +1,41 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 1.9.1 (2020/12/07)
|
||||||
|
|
||||||
|
* Replace forbidden chars derived from branch name (#31)
|
||||||
|
* Bump semver from 7.3.2 to 7.3.4 (#26)
|
||||||
|
|
||||||
|
## 1.9.0 (2020/12/04)
|
||||||
|
|
||||||
|
* Allow to add custom tags (#24)
|
||||||
|
* Allow to disable latest tag (#23)
|
||||||
|
* Warn on invalid semver (#22)
|
||||||
|
* Avoid unnecessary calls to version (#21)
|
||||||
|
|
||||||
|
## 1.8.5 (2020/11/24)
|
||||||
|
|
||||||
|
* Use sepLabels when joining labels for output (#17)
|
||||||
|
|
||||||
|
## 1.8.4 (2020/11/20)
|
||||||
|
|
||||||
|
* Pre-release (rc, beta, alpha) will only extend `{{version}}` as tag for `tag-semver`
|
||||||
|
|
||||||
|
## 1.8.3 (2020/11/20)
|
||||||
|
|
||||||
|
* Lowercase image name (#16)
|
||||||
|
|
||||||
|
## 1.8.2 (2020/11/18)
|
||||||
|
|
||||||
|
* Remove duplicated tags
|
||||||
|
|
||||||
|
## 1.8.1 (2020/11/18)
|
||||||
|
|
||||||
|
* Missing input in `action.yml`
|
||||||
|
|
||||||
|
## 1.8.0 (2020/11/17)
|
||||||
|
|
||||||
|
* Handle semver tags (#14)
|
||||||
|
|
||||||
## 1.7.0 (2020/10/31)
|
## 1.7.0 (2020/10/31)
|
||||||
|
|
||||||
* Use `repo.html_url` for `org.opencontainers.image.source` label to be able to display README on GHCR
|
* Use `repo.html_url` for `org.opencontainers.image.source` label to be able to display README on GHCR
|
||||||
|
203
README.md
203
README.md
@@ -17,13 +17,16 @@ If you are interested, [check out](https://git.io/Je09Y) my other :octocat: GitH
|
|||||||
___
|
___
|
||||||
|
|
||||||
* [Features](#features)
|
* [Features](#features)
|
||||||
* [Overview](#overview)
|
|
||||||
* [Usage](#usage)
|
* [Usage](#usage)
|
||||||
|
* [Basic](#basic)
|
||||||
|
* [Semver](#semver)
|
||||||
|
* [Complete](#complete)
|
||||||
* [Customizing](#customizing)
|
* [Customizing](#customizing)
|
||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
* [outputs](#outputs)
|
* [outputs](#outputs)
|
||||||
* [Notes](#notes)
|
* [Notes](#notes)
|
||||||
* [Latest tag](#latest-tag)
|
* [Latest tag](#latest-tag)
|
||||||
|
* [Handle semver tag](#handle-semver-tag)
|
||||||
* [`tag-match` examples](#tag-match-examples)
|
* [`tag-match` examples](#tag-match-examples)
|
||||||
* [Schedule tag](#schedule-tag)
|
* [Schedule tag](#schedule-tag)
|
||||||
* [Overwrite labels](#overwrite-labels)
|
* [Overwrite labels](#overwrite-labels)
|
||||||
@@ -37,29 +40,27 @@ ___
|
|||||||
* [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md) used to generate Docker labels
|
* [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md) used to generate Docker labels
|
||||||
* [Handlebars template](https://handlebarsjs.com/guide/) to apply to schedule tag
|
* [Handlebars template](https://handlebarsjs.com/guide/) to apply to schedule tag
|
||||||
|
|
||||||
## Overview
|
## Usage
|
||||||
|
|
||||||
|
### Basic
|
||||||
|
|
||||||
| Event | Ref | Commit SHA | Docker Tags |
|
| Event | Ref | Commit SHA | Docker Tags |
|
||||||
|-----------------|-------------------------------|------------|-------------------------------------|
|
|-----------------|-------------------------------|------------|-------------------------------------|
|
||||||
| `schedule` | `refs/heads/master` | `45f132a` | `sha-45f132a`, `nightly` |
|
| `pull_request` | `refs/pull/2/merge` | `a123b57` | `pr-2` |
|
||||||
| `pull_request` | `refs/pull/2/merge` | `a123b57` | `sha-a123b57`, `pr-2` |
|
| `push` | `refs/heads/master` | `cf20257` | `master` |
|
||||||
| `push` | `refs/heads/master` | `cf20257` | `sha-cf20257`, `master` |
|
| `push` | `refs/heads/my/branch` | `a5df687` | `my-branch` |
|
||||||
| `push` | `refs/heads/my/branch` | `a5df687` | `sha-a5df687`, `my-branch` |
|
| `push tag` | `refs/tags/v1.2.3` | `ad132f5` | `v1.2.3`, `latest` |
|
||||||
| `push tag` | `refs/tags/v1.2.3` | `bf4565b` | `sha-bf4565b`, `v1.2.3`, `latest` |
|
| `push tag` | `refs/tags/v2.0.8-beta.67` | `fc89efd` | `v2.0.8-beta.67`, `latest` |
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: ci
|
name: ci
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
|
||||||
- cron: '0 10 * * *' # everyday at 10am
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- '**'
|
||||||
tags:
|
tags:
|
||||||
- 'v*.*.*'
|
- 'v*'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -100,6 +101,134 @@ jobs:
|
|||||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Semver
|
||||||
|
|
||||||
|
| Event | Ref | Commit SHA | Docker Tags |
|
||||||
|
|-----------------|-------------------------------|------------|-------------------------------------|
|
||||||
|
| `pull_request` | `refs/pull/2/merge` | `a123b57` | `pr-2` |
|
||||||
|
| `push` | `refs/heads/master` | `cf20257` | `master` |
|
||||||
|
| `push` | `refs/heads/my/branch` | `a5df687` | `my-branch` |
|
||||||
|
| `push tag` | `refs/tags/v1.2.3` | `ad132f5` | `1.2.3`, `1.2`, `latest` |
|
||||||
|
| `push tag` | `refs/tags/v2.0.8-beta.67` | `fc89efd` | `2.0.8-beta.67` |
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '**'
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
id: docker_meta
|
||||||
|
uses: crazy-max/ghaction-docker-meta@v1
|
||||||
|
with:
|
||||||
|
images: name/app
|
||||||
|
tag-semver: |
|
||||||
|
{{version}}
|
||||||
|
{{major}}.{{minor}}
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
-
|
||||||
|
name: Login to DockerHub
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Build and push
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64,linux/386
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Complete
|
||||||
|
|
||||||
|
| Event | Ref | Commit SHA | Docker Tags |
|
||||||
|
|-----------------|-------------------------------|------------|-----------------------------------------|
|
||||||
|
| `schedule` | `refs/heads/master` | `45f132a` | `sha-45f132a`, `nightly` |
|
||||||
|
| `pull_request` | `refs/pull/2/merge` | `a123b57` | `sha-a123b57`, `pr-2` |
|
||||||
|
| `push` | `refs/heads/master` | `cf20257` | `sha-cf20257`, `master` |
|
||||||
|
| `push` | `refs/heads/my/branch` | `a5df687` | `sha-a5df687`, `my-branch` |
|
||||||
|
| `push tag` | `refs/tags/v1.2.3` | `ad132f5` | `sha-ad132f5`, `1.2.3`, `1.2`, `latest` |
|
||||||
|
| `push tag` | `refs/tags/v2.0.8-beta.67` | `fc89efd` | `sha-fc89efd`, `2.0.8-beta.67` |
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 10 * * *' # everyday at 10am
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '**'
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
id: docker_meta
|
||||||
|
uses: crazy-max/ghaction-docker-meta@v1
|
||||||
|
with:
|
||||||
|
images: name/app
|
||||||
|
tag-sha: true
|
||||||
|
tag-semver: |
|
||||||
|
{{version}}
|
||||||
|
{{major}}.{{minor}}
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
-
|
||||||
|
name: Login to DockerHub
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Build and push
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64,linux/386
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||||
|
```
|
||||||
|
|
||||||
## Customizing
|
## Customizing
|
||||||
|
|
||||||
### inputs
|
### inputs
|
||||||
@@ -112,15 +241,20 @@ Following inputs can be used as `step.with` keys
|
|||||||
| `tag-sha` | Bool | Add git short SHA as Docker tag (default `false`) |
|
| `tag-sha` | Bool | Add git short SHA as Docker tag (default `false`) |
|
||||||
| `tag-edge` | Bool | Enable edge branch tagging (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-edge-branch` | String | Branch that will be tagged as edge (default `repo.default_branch`) |
|
||||||
|
| `tag-semver` | List/CSV | Handle Git tag as semver [template](#handle-semver-tag) if possible |
|
||||||
| `tag-match` | String | RegExp to match against a Git tag and use first match as Docker tag |
|
| `tag-match` | String | RegExp to match against a Git tag and use first match as Docker tag |
|
||||||
| `tag-match-group` | Number | Group to get if `tag-match` matches (default `0`) |
|
| `tag-match-group` | Number | Group to get if `tag-match` matches (default `0`) |
|
||||||
| `tag-match-latest` | Bool | Set `latest` Docker tag if `tag-match` matches or on Git tag event (default `true`) |
|
| `tag-latest` | Bool | Set `latest` Docker tag if `tag-semver`, `tag-match` or Git tag event occurs (default `true`) |
|
||||||
| `tag-schedule` | String | [Template](#schedule-tag) to apply to schedule tag (default `nightly`) |
|
| `tag-schedule` | String | [Template](#schedule-tag) to apply to schedule tag (default `nightly`) |
|
||||||
|
| `tag-custom` | List/CSV | List of custom tags |
|
||||||
|
| `tag-custom-only` | Bool | Only use `tag-custom` as Docker tags |
|
||||||
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
|
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
|
||||||
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
|
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
|
||||||
|
|
||||||
> List/CSV type can be a newline or comma delimited string
|
> List/CSV type can be a newline or comma delimited string
|
||||||
|
|
||||||
|
> `tag-semver` and `tag-match` are mutually exclusive
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|
||||||
Following outputs are available
|
Following outputs are available
|
||||||
@@ -135,19 +269,44 @@ Following outputs are available
|
|||||||
|
|
||||||
### Latest tag
|
### Latest tag
|
||||||
|
|
||||||
Latest Docker tag will be generated by default on `push tag` event. So if for example you push the `v1.2.3` Git tag,
|
Latest Docker tag will be generated by default on `push tag` event. If for example you push the `v1.2.3` Git tag,
|
||||||
you will have at the output of this action the Docker tags `v1.2.3` and `latest`. But you can allow the latest tag to be
|
you will have at the output of this action the Docker tags `v1.2.3` and `latest`. But you can allow the latest tag to be
|
||||||
generated only if the Git tag matches a regular expression with the [`tag-match` input](#tag-match-examples).
|
generated only if `tag-semver` is a valid [semver](https://semver.org/) or if Git tag matches a regular expression
|
||||||
|
with the [`tag-match` input](#tag-match-examples). Can be disabled if `tag-latest` is `false`.
|
||||||
|
|
||||||
|
### Handle semver tag
|
||||||
|
|
||||||
|
If Git tag is a valid [semver](https://semver.org/) you can handle it to output multi Docker tags at once.
|
||||||
|
`tag-semver` supports multi-line [Handlebars template](https://handlebarsjs.com/guide/) with the following inputs:
|
||||||
|
|
||||||
|
| Git tag | `tag-semver` | Valid | Output tags | Output version |
|
||||||
|
|--------------------|----------------------------------------------------------|--------------------|----------------------------|------------------------------|
|
||||||
|
| `v1.2.3` | `{{raw}}` | :white_check_mark: | `v1.2.3`, `latest` | `v1.2.3` |
|
||||||
|
| `v1.2.3` | `{{version}}` | :white_check_mark: | `1.2.3`, `latest` | `1.2.3` |
|
||||||
|
| `v1.2.3` | `{{major}}.{{minor}}` | :white_check_mark: | `1.2`, `latest` | `1.2` |
|
||||||
|
| `v1.2.3` | `v{{major}}` | :white_check_mark: | `v1`, `latest` | `v1` |
|
||||||
|
| `v1.2.3` | `{{minor}}` | :white_check_mark: | `2`, `latest` | `2` |
|
||||||
|
| `v1.2.3` | `{{patch}}` | :white_check_mark: | `3`, `latest` | `3` |
|
||||||
|
| `v1.2.3` | `{{major}}.{{minor}}`<br>`{{major}}.{{minor}}.{{patch}}` | :white_check_mark: | `1.2`, `1.2.3`, `latest` | `1.2`* |
|
||||||
|
| `v2.0.8-beta.67` | `{{raw}}` | :white_check_mark: | `2.0.8-beta.67`** | `2.0.8-beta.67` |
|
||||||
|
| `v2.0.8-beta.67` | `{{version}}` | :white_check_mark: | `2.0.8-beta.67` | `2.0.8-beta.67` |
|
||||||
|
| `v2.0.8-beta.67` | `{{major}}.{{minor}}` | :white_check_mark: | `2.0.8-beta.67`** | `2.0.8-beta.67` |
|
||||||
|
| `release1` | `{{raw}}` | :x: | `release1` | `release1` |
|
||||||
|
|
||||||
|
> *First occurrence of `tag-semver` will be taken as `output.version`
|
||||||
|
|
||||||
|
> **Pre-release (rc, beta, alpha) will only extend `{{version}}` as tag because they are updated frequently,
|
||||||
|
> and contain many breaking changes that are (by the author's design) not yet fit for public consumption.
|
||||||
|
|
||||||
### `tag-match` examples
|
### `tag-match` examples
|
||||||
|
|
||||||
| Git tag | `tag-match` | `tag-match-group` | Match | Docker tags |
|
| Git tag | `tag-match` | `tag-match-group` | Match | Output tags | Output version |
|
||||||
|-------------------------|------------------------------------|-------------------|----------------------|---------------------------|
|
|-------------------------|------------------------------------|-------------------|----------------------|---------------------------|------------------------------|
|
||||||
| `v1.2.3` | `\d{1,3}.\d{1,3}.\d{1,3}` | `0` | :white_check_mark: | `1.2.3`, `latest` |
|
| `v1.2.3` | `\d{1,3}.\d{1,3}.\d{1,3}` | `0` | :white_check_mark: | `1.2.3`, `latest` | `1.2.3` |
|
||||||
| `v2.0.8-beta.67` | `v(.*)` | `1` | :white_check_mark: | `2.0.8-beta.67`, `latest` |
|
| `v2.0.8-beta.67` | `v(.*)` | `1` | :white_check_mark: | `2.0.8-beta.67`, `latest` | `2.0.8-beta.67` |
|
||||||
| `v2.0.8-beta.67` | `v(\d.\d)` | `1` | :white_check_mark: | `2.0`, `latest` |
|
| `v2.0.8-beta.67` | `v(\d.\d)` | `1` | :white_check_mark: | `2.0`, `latest` | `2.0` |
|
||||||
| `release1` | `\d{1,3}.\d{1,3}` | `0` | :x: | `release1` |
|
| `release1` | `\d{1,3}.\d{1,3}` | `0` | :x: | `release1` | `release1` |
|
||||||
| `20200110-RC2` | `\d+` | `0` | :white_check_mark: | `20200110`, `latest` |
|
| `20200110-RC2` | `\d+` | `0` | :white_check_mark: | `20200110`, `latest` | `20200110` |
|
||||||
|
|
||||||
### Schedule tag
|
### Schedule tag
|
||||||
|
|
||||||
|
23
__tests__/fixtures/event_push_invalidchars.env
Normal file
23
__tests__/fixtures/event_push_invalidchars.env
Normal 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_89a016e8-e5b7-4039-a67e-c8da08f87a0c
|
||||||
|
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_89a016e8-e5b7-4039-a67e-c8da08f87a0c
|
||||||
|
GITHUB_REF="refs/heads/my/feature#1245"
|
||||||
|
GITHUB_REPOSITORY=crazy-max/test-docker-action
|
||||||
|
GITHUB_REPOSITORY_OWNER=crazy-max
|
||||||
|
GITHUB_RETENTION_DAYS=90
|
||||||
|
GITHUB_RUN_ID=325957516
|
||||||
|
GITHUB_RUN_NUMBER=1
|
||||||
|
GITHUB_SERVER_URL=https://github.com
|
||||||
|
GITHUB_SHA=90dd6032fac8bda1b6c4436a2e65de27961ed071
|
||||||
|
GITHUB_WORKFLOW=event
|
||||||
|
GITHUB_WORKSPACE=/home/runner/work/test-docker-action/test-docker-action
|
@@ -44,7 +44,7 @@ const tagsLabelsTest = async (envFile: string, inputs: Inputs, exVersion: Versio
|
|||||||
const repo = await github.repo(process.env.GITHUB_TOKEN || '');
|
const repo = await github.repo(process.env.GITHUB_TOKEN || '');
|
||||||
const meta = new Meta({...getInputs(), ...inputs}, context, repo);
|
const meta = new Meta({...getInputs(), ...inputs}, context, repo);
|
||||||
|
|
||||||
const version = meta.version();
|
const version = meta.version;
|
||||||
console.log('version', version);
|
console.log('version', version);
|
||||||
expect(version).toEqual(exVersion);
|
expect(version).toEqual(exVersion);
|
||||||
|
|
||||||
@@ -66,7 +66,8 @@ describe('null', () => {
|
|||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: undefined,
|
main: undefined,
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[],
|
[],
|
||||||
@@ -87,7 +88,8 @@ describe('null', () => {
|
|||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: undefined,
|
main: undefined,
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[],
|
[],
|
||||||
@@ -114,7 +116,8 @@ describe('push', () => {
|
|||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'dev',
|
main: 'dev',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -138,7 +141,8 @@ describe('push', () => {
|
|||||||
tagEdge: true,
|
tagEdge: true,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'edge',
|
main: 'edge',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -161,7 +165,8 @@ describe('push', () => {
|
|||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'master',
|
main: 'master',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -185,7 +190,8 @@ describe('push', () => {
|
|||||||
tagEdge: true,
|
tagEdge: true,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'edge',
|
main: 'edge',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -208,7 +214,8 @@ describe('push', () => {
|
|||||||
images: ['org/app', 'ghcr.io/user/app'],
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'dev',
|
main: 'dev',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -233,7 +240,8 @@ describe('push', () => {
|
|||||||
tagEdge: true,
|
tagEdge: true,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'edge',
|
main: 'edge',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -258,7 +266,8 @@ describe('push', () => {
|
|||||||
tagSha: true,
|
tagSha: true,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'dev',
|
main: 'dev',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -286,7 +295,8 @@ describe('push', () => {
|
|||||||
tagEdge: true,
|
tagEdge: true,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'edge',
|
main: 'edge',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -315,7 +325,8 @@ describe('push', () => {
|
|||||||
tagEdgeBranch: 'dev'
|
tagEdgeBranch: 'dev'
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'edge',
|
main: 'edge',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -344,7 +355,8 @@ describe('push', () => {
|
|||||||
tagEdgeBranch: 'dev'
|
tagEdgeBranch: 'dev'
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'master',
|
main: 'master',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -364,6 +376,35 @@ describe('push', () => {
|
|||||||
"org.opencontainers.image.licenses=MIT"
|
"org.opencontainers.image.licenses=MIT"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'event_push_invalidchars.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tagSha: true,
|
||||||
|
tagEdge: true,
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'my-feature-1245',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:my-feature-1245',
|
||||||
|
'org/app:sha-90dd603',
|
||||||
|
'ghcr.io/user/app:my-feature-1245',
|
||||||
|
'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",
|
||||||
|
"org.opencontainers.image.version=my-feature-1245",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
])('given %p event ', tagsLabelsTest);
|
])('given %p event ', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -376,7 +417,8 @@ describe('push tag', () => {
|
|||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'release1',
|
main: 'release1',
|
||||||
|
partial: [],
|
||||||
latest: true
|
latest: true
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -400,7 +442,8 @@ describe('push tag', () => {
|
|||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '20200110-RC2',
|
main: '20200110-RC2',
|
||||||
|
partial: [],
|
||||||
latest: true
|
latest: true
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -423,10 +466,11 @@ describe('push tag', () => {
|
|||||||
{
|
{
|
||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
tagMatch: `\\d{8}`,
|
tagMatch: `\\d{8}`,
|
||||||
tagMatchLatest: false,
|
tagLatest: false,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '20200110',
|
main: '20200110',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -449,10 +493,11 @@ describe('push tag', () => {
|
|||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
tagMatch: `(.*)-RC`,
|
tagMatch: `(.*)-RC`,
|
||||||
tagMatchGroup: 1,
|
tagMatchGroup: 1,
|
||||||
tagMatchLatest: false,
|
tagLatest: false,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '20200110',
|
main: '20200110',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -476,7 +521,37 @@ describe('push tag', () => {
|
|||||||
tagMatch: `\\d{1,3}.\\d{1,3}.\\d{1,3}`,
|
tagMatch: `\\d{1,3}.\\d{1,3}.\\d{1,3}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '1.1.1',
|
main: '1.1.1',
|
||||||
|
partial: [],
|
||||||
|
latest: true
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'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",
|
||||||
|
"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_tag_v1.1.1.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tagMatch: `^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$`,
|
||||||
|
tagMatchGroup: 1,
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: '1.1.1',
|
||||||
|
partial: [],
|
||||||
latest: true
|
latest: true
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -503,7 +578,8 @@ describe('push tag', () => {
|
|||||||
tagMatch: `\\d{1,3}.\\d{1,3}.\\d{1,3}-(alpha|beta).\\d{1,3}`,
|
tagMatch: `\\d{1,3}.\\d{1,3}.\\d{1,3}-(alpha|beta).\\d{1,3}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '2.0.8-beta.67',
|
main: '2.0.8-beta.67',
|
||||||
|
partial: [],
|
||||||
latest: true
|
latest: true
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -530,7 +606,8 @@ describe('push tag', () => {
|
|||||||
tagMatch: `\\d{1,3}.\\d{1,3}`,
|
tagMatch: `\\d{1,3}.\\d{1,3}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '2.0',
|
main: '2.0',
|
||||||
|
partial: [],
|
||||||
latest: true
|
latest: true
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -550,6 +627,33 @@ describe('push tag', () => {
|
|||||||
"org.opencontainers.image.licenses=MIT"
|
"org.opencontainers.image.licenses=MIT"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'event_tag_v2.0.8-beta.67.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tagMatch: `^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$`,
|
||||||
|
tagMatchGroup: 1,
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'v2.0.8-beta.67',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:v2.0.8-beta.67',
|
||||||
|
'ghcr.io/user/app:v2.0.8-beta.67'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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",
|
||||||
|
"org.opencontainers.image.version=v2.0.8-beta.67",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'event_tag_sometag.env',
|
'event_tag_sometag.env',
|
||||||
{
|
{
|
||||||
@@ -557,7 +661,8 @@ describe('push tag', () => {
|
|||||||
tagMatch: `\\d{1,3}.\\d{1,3}`,
|
tagMatch: `\\d{1,3}.\\d{1,3}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'sometag',
|
main: 'sometag',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -575,6 +680,118 @@ describe('push tag', () => {
|
|||||||
"org.opencontainers.image.licenses=MIT"
|
"org.opencontainers.image.licenses=MIT"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'event_tag_v1.1.1.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tagSemver: ['{{version}}', '{{major}}.{{minor}}', '{{major}}'],
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: '1.1.1',
|
||||||
|
partial: ['1.1', '1'],
|
||||||
|
latest: true
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:1.1.1',
|
||||||
|
'org/app:1.1',
|
||||||
|
'org/app:1',
|
||||||
|
'org/app:latest',
|
||||||
|
'ghcr.io/user/app:1.1.1',
|
||||||
|
'ghcr.io/user/app:1.1',
|
||||||
|
'ghcr.io/user/app: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",
|
||||||
|
"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_tag_v1.1.1.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tagSemver: ['{{version}}', '{{major}}.{{minor}}.{{patch}}'],
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: '1.1.1',
|
||||||
|
partial: [],
|
||||||
|
latest: true
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'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",
|
||||||
|
"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_tag_v2.0.8-beta.67.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tagSemver: ['{{major}}.{{minor}}', '{{major}}'],
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: '2.0.8-beta.67',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:2.0.8-beta.67',
|
||||||
|
'ghcr.io/user/app:2.0.8-beta.67'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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",
|
||||||
|
"org.opencontainers.image.version=2.0.8-beta.67",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'event_tag_sometag.env',
|
||||||
|
{
|
||||||
|
images: ['ghcr.io/user/app'],
|
||||||
|
tagSemver: ['{{version}}', '{{major}}.{{minor}}', '{{major}}'],
|
||||||
|
tagLatest: false,
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'sometag',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'ghcr.io/user/app:sometag'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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",
|
||||||
|
"org.opencontainers.image.version=sometag",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
])('given %p event ', tagsLabelsTest);
|
])('given %p event ', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -588,7 +805,8 @@ describe('latest', () => {
|
|||||||
tagMatch: `^release\\d{1,2}`,
|
tagMatch: `^release\\d{1,2}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'release1',
|
main: 'release1',
|
||||||
|
partial: [],
|
||||||
latest: true,
|
latest: true,
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -613,7 +831,8 @@ describe('latest', () => {
|
|||||||
tagMatch: `^\\d+-RC\\d{1,2}`,
|
tagMatch: `^\\d+-RC\\d{1,2}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '20200110-RC2',
|
main: '20200110-RC2',
|
||||||
|
partial: [],
|
||||||
latest: true
|
latest: true
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -638,7 +857,8 @@ describe('latest', () => {
|
|||||||
tagMatch: `\\d{8}`,
|
tagMatch: `\\d{8}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '20200110',
|
main: '20200110',
|
||||||
|
partial: [],
|
||||||
latest: true
|
latest: true
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -663,7 +883,8 @@ describe('latest', () => {
|
|||||||
tagMatch: `\\d{1,3}.\\d{1,3}.\\d{1,3}`,
|
tagMatch: `\\d{1,3}.\\d{1,3}.\\d{1,3}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '1.1.1',
|
main: '1.1.1',
|
||||||
|
partial: [],
|
||||||
latest: true
|
latest: true
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -687,7 +908,8 @@ describe('latest', () => {
|
|||||||
images: ['org/app', 'ghcr.io/user/app'],
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'v1.1.1',
|
main: 'v1.1.1',
|
||||||
|
partial: [],
|
||||||
latest: true
|
latest: true
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -714,7 +936,8 @@ describe('latest', () => {
|
|||||||
tagMatch: `\\d{1,3}.\\d{1,3}.\\d{1,3}`,
|
tagMatch: `\\d{1,3}.\\d{1,3}.\\d{1,3}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '2.0.8',
|
main: '2.0.8',
|
||||||
|
partial: [],
|
||||||
latest: true
|
latest: true
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -738,10 +961,11 @@ describe('latest', () => {
|
|||||||
'event_tag_v1.1.1.env',
|
'event_tag_v1.1.1.env',
|
||||||
{
|
{
|
||||||
images: ['org/app', 'ghcr.io/user/app'],
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
tagMatchLatest: false,
|
tagLatest: false,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'v1.1.1',
|
main: 'v1.1.1',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -759,6 +983,32 @@ describe('latest', () => {
|
|||||||
"org.opencontainers.image.licenses=MIT"
|
"org.opencontainers.image.licenses=MIT"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'event_tag_v1.1.1.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/MyUSER/MyApp'],
|
||||||
|
tagLatest: false,
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'v1.1.1',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:v1.1.1',
|
||||||
|
'ghcr.io/myuser/myapp:v1.1.1',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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",
|
||||||
|
"org.opencontainers.image.version=v1.1.1",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
])('given %p event ', tagsLabelsTest);
|
])('given %p event ', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -771,7 +1021,8 @@ describe('pull_request', () => {
|
|||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'pr-2',
|
main: 'pr-2',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -794,7 +1045,8 @@ describe('pull_request', () => {
|
|||||||
images: ['org/app', 'ghcr.io/user/app'],
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'pr-2',
|
main: 'pr-2',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -819,7 +1071,8 @@ describe('pull_request', () => {
|
|||||||
tagSha: true,
|
tagSha: true,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'pr-2',
|
main: 'pr-2',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -851,7 +1104,8 @@ describe('schedule', () => {
|
|||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'nightly',
|
main: 'nightly',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -875,7 +1129,8 @@ describe('schedule', () => {
|
|||||||
tagSchedule: `{{date 'YYYYMMDD'}}`
|
tagSchedule: `{{date 'YYYYMMDD'}}`
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '20200110',
|
main: '20200110',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -899,7 +1154,8 @@ describe('schedule', () => {
|
|||||||
tagSchedule: `{{date 'YYYYMMDD-HHmmss'}}`
|
tagSchedule: `{{date 'YYYYMMDD-HHmmss'}}`
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '20200110-003000',
|
main: '20200110-003000',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -922,7 +1178,8 @@ describe('schedule', () => {
|
|||||||
images: ['org/app', 'ghcr.io/user/app'],
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'nightly',
|
main: 'nightly',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -947,7 +1204,8 @@ describe('schedule', () => {
|
|||||||
tagSha: true,
|
tagSha: true,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'nightly',
|
main: 'nightly',
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -979,7 +1237,8 @@ describe('release', () => {
|
|||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'v1.1.1',
|
main: 'v1.1.1',
|
||||||
|
partial: [],
|
||||||
latest: true
|
latest: true
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
@@ -999,3 +1258,193 @@ describe('release', () => {
|
|||||||
],
|
],
|
||||||
])('given %p event ', tagsLabelsTest);
|
])('given %p event ', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('custom', () => {
|
||||||
|
// prettier-ignore
|
||||||
|
test.each([
|
||||||
|
[
|
||||||
|
'event_push.env',
|
||||||
|
{
|
||||||
|
images: ['user/app'],
|
||||||
|
tagCustom: ['my', 'custom', 'tags']
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'dev',
|
||||||
|
partial: ['my', 'custom', 'tags'],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'user/app:dev',
|
||||||
|
'user/app:my',
|
||||||
|
'user/app:custom',
|
||||||
|
'user/app:tags'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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",
|
||||||
|
"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.env',
|
||||||
|
{
|
||||||
|
images: ['user/app'],
|
||||||
|
tagCustom: ['my']
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'dev',
|
||||||
|
partial: ['my'],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'user/app:dev',
|
||||||
|
'user/app:my'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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",
|
||||||
|
"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_tag_release1.env',
|
||||||
|
{
|
||||||
|
images: ['user/app'],
|
||||||
|
tagCustom: ['my', 'custom', 'tags']
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'release1',
|
||||||
|
partial: ['my', 'custom', 'tags'],
|
||||||
|
latest: true
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'user/app:release1',
|
||||||
|
'user/app:my',
|
||||||
|
'user/app:custom',
|
||||||
|
'user/app:tags',
|
||||||
|
'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",
|
||||||
|
"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_20200110-RC2.env',
|
||||||
|
{
|
||||||
|
images: ['user/app'],
|
||||||
|
tagMatch: `\\d{8}`,
|
||||||
|
tagLatest: false,
|
||||||
|
tagCustom: ['my', 'custom', 'tags']
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: '20200110',
|
||||||
|
partial: ['my', 'custom', 'tags'],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'user/app:20200110',
|
||||||
|
'user/app:my',
|
||||||
|
'user/app:custom',
|
||||||
|
'user/app:tags'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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",
|
||||||
|
"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_tag_v1.1.1.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tagSemver: ['{{version}}', '{{major}}.{{minor}}', '{{major}}'],
|
||||||
|
tagCustom: ['my', 'custom', 'tags']
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: '1.1.1',
|
||||||
|
partial: ['1.1', '1', 'my', 'custom', 'tags'],
|
||||||
|
latest: true
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:1.1.1',
|
||||||
|
'org/app:1.1',
|
||||||
|
'org/app:1',
|
||||||
|
'org/app:my',
|
||||||
|
'org/app:custom',
|
||||||
|
'org/app:tags',
|
||||||
|
'org/app:latest',
|
||||||
|
'ghcr.io/user/app:1.1.1',
|
||||||
|
'ghcr.io/user/app:1.1',
|
||||||
|
'ghcr.io/user/app:1',
|
||||||
|
'ghcr.io/user/app:my',
|
||||||
|
'ghcr.io/user/app:custom',
|
||||||
|
'ghcr.io/user/app:tags',
|
||||||
|
'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",
|
||||||
|
"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_tag_v1.1.1.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tagSemver: ['{{version}}', '{{major}}.{{minor}}.{{patch}}'],
|
||||||
|
tagCustom: ['my', 'custom', 'tags'],
|
||||||
|
tagCustomOnly: true,
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'my',
|
||||||
|
partial: ['custom', 'tags'],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:my',
|
||||||
|
'org/app:custom',
|
||||||
|
'org/app:tags',
|
||||||
|
'ghcr.io/user/app:my',
|
||||||
|
'ghcr.io/user/app:custom',
|
||||||
|
'ghcr.io/user/app:tags'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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",
|
||||||
|
"org.opencontainers.image.version=my",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
])('given %p event ', tagsLabelsTest);
|
||||||
|
});
|
||||||
|
16
action.yml
16
action.yml
@@ -21,6 +21,9 @@ inputs:
|
|||||||
tag-edge-branch:
|
tag-edge-branch:
|
||||||
description: 'Branch that will be tagged as edge (default repo.default_branch)'
|
description: 'Branch that will be tagged as edge (default repo.default_branch)'
|
||||||
required: false
|
required: false
|
||||||
|
tag-semver:
|
||||||
|
description: 'Handle Git tag as semver template if possible'
|
||||||
|
required: false
|
||||||
tag-match:
|
tag-match:
|
||||||
description: 'RegExp to match against a Git tag and use match group as Docker tag'
|
description: 'RegExp to match against a Git tag and use match group as Docker tag'
|
||||||
required: false
|
required: false
|
||||||
@@ -28,14 +31,25 @@ inputs:
|
|||||||
description: 'Group to get if tag-match matches (default 0)'
|
description: 'Group to get if tag-match matches (default 0)'
|
||||||
default: '0'
|
default: '0'
|
||||||
required: false
|
required: false
|
||||||
|
tag-latest:
|
||||||
|
description: 'Set latest Docker tag if tag-semver, tag-match or Git tag event occurs'
|
||||||
|
default: 'true'
|
||||||
|
required: false
|
||||||
tag-match-latest:
|
tag-match-latest:
|
||||||
description: 'Set latest Docker tag if tag-match matches or on Git tag event'
|
deprecationMessage: 'tag-match-latest is deprecated. Use tag-latest instead'
|
||||||
|
description: '(DEPRECATED) Set latest Docker tag if tag-match matches or on Git tag event'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
tag-schedule:
|
tag-schedule:
|
||||||
description: 'Template to apply to schedule tag'
|
description: 'Template to apply to schedule tag'
|
||||||
default: 'nightly'
|
default: 'nightly'
|
||||||
required: false
|
required: false
|
||||||
|
tag-custom:
|
||||||
|
description: 'List of custom tags'
|
||||||
|
required: false
|
||||||
|
tag-custom-only:
|
||||||
|
description: 'Only use tag-custom as Docker tags'
|
||||||
|
required: false
|
||||||
sep-tags:
|
sep-tags:
|
||||||
description: 'Separator to use for tags output (default \n)'
|
description: 'Separator to use for tags output (default \n)'
|
||||||
required: false
|
required: false
|
||||||
|
3099
dist/index.js
generated
vendored
3099
dist/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,8 @@
|
|||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/github": "^4.0.0",
|
"@actions/github": "^4.0.0",
|
||||||
"handlebars": "^4.7.6",
|
"handlebars": "^4.7.6",
|
||||||
"moment": "^2.29.1"
|
"moment": "^2.29.1",
|
||||||
|
"semver": "^7.3.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.0",
|
"@types/jest": "^26.0.0",
|
||||||
|
@@ -5,10 +5,13 @@ export interface Inputs {
|
|||||||
tagSha: boolean;
|
tagSha: boolean;
|
||||||
tagEdge: boolean;
|
tagEdge: boolean;
|
||||||
tagEdgeBranch: string;
|
tagEdgeBranch: string;
|
||||||
|
tagSemver: string[];
|
||||||
tagMatch: string;
|
tagMatch: string;
|
||||||
tagMatchGroup: number;
|
tagMatchGroup: number;
|
||||||
tagMatchLatest: boolean;
|
tagLatest: boolean;
|
||||||
tagSchedule: string;
|
tagSchedule: string;
|
||||||
|
tagCustom: string[];
|
||||||
|
tagCustomOnly: boolean;
|
||||||
sepTags: string;
|
sepTags: string;
|
||||||
sepLabels: string;
|
sepLabels: string;
|
||||||
githubToken: string;
|
githubToken: string;
|
||||||
@@ -20,10 +23,13 @@ export function getInputs(): Inputs {
|
|||||||
tagSha: /true/i.test(core.getInput('tag-sha') || 'false'),
|
tagSha: /true/i.test(core.getInput('tag-sha') || 'false'),
|
||||||
tagEdge: /true/i.test(core.getInput('tag-edge') || 'false'),
|
tagEdge: /true/i.test(core.getInput('tag-edge') || 'false'),
|
||||||
tagEdgeBranch: core.getInput('tag-edge-branch'),
|
tagEdgeBranch: core.getInput('tag-edge-branch'),
|
||||||
|
tagSemver: getInputList('tag-semver'),
|
||||||
tagMatch: core.getInput('tag-match'),
|
tagMatch: core.getInput('tag-match'),
|
||||||
tagMatchGroup: Number(core.getInput('tag-match-group')) || 0,
|
tagMatchGroup: Number(core.getInput('tag-match-group')) || 0,
|
||||||
tagMatchLatest: /true/i.test(core.getInput('tag-match-latest') || 'true'),
|
tagLatest: /true/i.test(core.getInput('tag-latest') || core.getInput('tag-match-latest') || 'true'),
|
||||||
tagSchedule: core.getInput('tag-schedule') || 'nightly',
|
tagSchedule: core.getInput('tag-schedule') || 'nightly',
|
||||||
|
tagCustom: getInputList('tag-custom'),
|
||||||
|
tagCustomOnly: /true/i.test(core.getInput('tag-custom-only') || 'false'),
|
||||||
sepTags: core.getInput('sep-tags') || `\n`,
|
sepTags: core.getInput('sep-tags') || `\n`,
|
||||||
sepLabels: core.getInput('sep-labels') || `\n`,
|
sepLabels: core.getInput('sep-labels') || `\n`,
|
||||||
githubToken: core.getInput('github-token')
|
githubToken: core.getInput('github-token')
|
||||||
|
@@ -27,11 +27,11 @@ async function run() {
|
|||||||
|
|
||||||
const meta: Meta = new Meta(inputs, context, repo);
|
const meta: Meta = new Meta(inputs, context, repo);
|
||||||
|
|
||||||
const version: Version = meta.version();
|
const version: Version = meta.version;
|
||||||
core.startGroup(`Docker image version`);
|
core.startGroup(`Docker image version`);
|
||||||
core.info(version.version || '');
|
core.info(version.main || '');
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
core.setOutput('version', version.version || '');
|
core.setOutput('version', version.main || '');
|
||||||
|
|
||||||
const tags: Array<string> = meta.tags();
|
const tags: Array<string> = meta.tags();
|
||||||
core.startGroup(`Docker tags`);
|
core.startGroup(`Docker tags`);
|
||||||
@@ -47,7 +47,7 @@ async function run() {
|
|||||||
core.info(label);
|
core.info(label);
|
||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
core.setOutput('labels', labels.join(inputs.sepTags));
|
core.setOutput('labels', labels.join(inputs.sepLabels));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
89
src/meta.ts
89
src/meta.ts
@@ -1,15 +1,20 @@
|
|||||||
import * as handlebars from 'handlebars';
|
import * as handlebars from 'handlebars';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
import * as semver from 'semver';
|
||||||
import {Inputs} from './context';
|
import {Inputs} from './context';
|
||||||
|
import * as core from '@actions/core';
|
||||||
import {Context} from '@actions/github/lib/context';
|
import {Context} from '@actions/github/lib/context';
|
||||||
import {ReposGetResponseData} from '@octokit/types';
|
import {ReposGetResponseData} from '@octokit/types';
|
||||||
|
|
||||||
export interface Version {
|
export interface Version {
|
||||||
version: string | undefined;
|
main: string | undefined;
|
||||||
|
partial: string[];
|
||||||
latest: boolean;
|
latest: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Meta {
|
export class Meta {
|
||||||
|
public readonly version: Version;
|
||||||
|
|
||||||
private readonly inputs: Inputs;
|
private readonly inputs: Inputs;
|
||||||
private readonly context: Context;
|
private readonly context: Context;
|
||||||
private readonly repo: ReposGetResponseData;
|
private readonly repo: ReposGetResponseData;
|
||||||
@@ -23,64 +28,102 @@ export class Meta {
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
this.date = new Date();
|
this.date = new Date();
|
||||||
|
this.version = this.getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public version(): Version {
|
private getVersion(): Version {
|
||||||
const currentDate = this.date;
|
const currentDate = this.date;
|
||||||
const version: Version = {
|
let version: Version = {
|
||||||
version: undefined,
|
main: undefined,
|
||||||
|
partial: [],
|
||||||
latest: false
|
latest: false
|
||||||
};
|
};
|
||||||
|
|
||||||
if (/schedule/.test(this.context.eventName)) {
|
if (/schedule/.test(this.context.eventName)) {
|
||||||
version.version = handlebars.compile(this.inputs.tagSchedule)({
|
version.main = handlebars.compile(this.inputs.tagSchedule)({
|
||||||
date: function (format) {
|
date: function (format) {
|
||||||
return moment(currentDate).utc().format(format);
|
return moment(currentDate).utc().format(format);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (/^refs\/tags\//.test(this.context.ref)) {
|
} else if (/^refs\/tags\//.test(this.context.ref)) {
|
||||||
version.version = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
version.main = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
||||||
if (this.inputs.tagMatch) {
|
if (this.inputs.tagSemver.length > 0 && !semver.valid(version.main)) {
|
||||||
|
core.warning(`${version.main} is not a valid semver. More info: https://semver.org/`);
|
||||||
|
}
|
||||||
|
if (this.inputs.tagSemver.length > 0 && semver.valid(version.main)) {
|
||||||
|
const sver = semver.parse(version.main, {
|
||||||
|
includePrerelease: true
|
||||||
|
});
|
||||||
|
if (semver.prerelease(version.main)) {
|
||||||
|
version.main = handlebars.compile('{{version}}')(sver);
|
||||||
|
} else {
|
||||||
|
version.latest = this.inputs.tagLatest;
|
||||||
|
version.main = handlebars.compile(this.inputs.tagSemver[0])(sver);
|
||||||
|
for (const semverTpl of this.inputs.tagSemver) {
|
||||||
|
const partial = handlebars.compile(semverTpl)(sver);
|
||||||
|
if (partial == version.main) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
version.partial.push(partial);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (this.inputs.tagMatch) {
|
||||||
let tagMatch;
|
let tagMatch;
|
||||||
const isRegEx = this.inputs.tagMatch.match(/^\/(.+)\/(.*)$/);
|
const isRegEx = this.inputs.tagMatch.match(/^\/(.+)\/(.*)$/);
|
||||||
if (isRegEx) {
|
if (isRegEx) {
|
||||||
tagMatch = version.version.match(new RegExp(isRegEx[1], isRegEx[2]));
|
tagMatch = version.main.match(new RegExp(isRegEx[1], isRegEx[2]));
|
||||||
} else {
|
} else {
|
||||||
tagMatch = version.version.match(this.inputs.tagMatch);
|
tagMatch = version.main.match(this.inputs.tagMatch);
|
||||||
}
|
}
|
||||||
if (tagMatch) {
|
if (tagMatch) {
|
||||||
version.version = tagMatch[this.inputs.tagMatchGroup];
|
version.main = tagMatch[this.inputs.tagMatchGroup];
|
||||||
version.latest = this.inputs.tagMatchLatest;
|
version.latest = this.inputs.tagLatest;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
version.latest = this.inputs.tagMatchLatest;
|
version.latest = this.inputs.tagLatest;
|
||||||
}
|
}
|
||||||
} else if (/^refs\/heads\//.test(this.context.ref)) {
|
} else if (/^refs\/heads\//.test(this.context.ref)) {
|
||||||
version.version = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');
|
version.main = this.context.ref.replace(/^refs\/heads\//g, '').replace(/[^a-zA-Z0-9._-]+/g, '-');
|
||||||
if (this.inputs.tagEdge && this.inputs.tagEdgeBranch === version.version) {
|
if (this.inputs.tagEdge && this.inputs.tagEdgeBranch === version.main) {
|
||||||
version.version = 'edge';
|
version.main = 'edge';
|
||||||
}
|
}
|
||||||
} else if (/^refs\/pull\//.test(this.context.ref)) {
|
} else if (/^refs\/pull\//.test(this.context.ref)) {
|
||||||
version.version = `pr-${this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '')}`;
|
version.main = `pr-${this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.inputs.tagCustom.length > 0) {
|
||||||
|
if (this.inputs.tagCustomOnly) {
|
||||||
|
version = {
|
||||||
|
main: this.inputs.tagCustom.shift(),
|
||||||
|
partial: this.inputs.tagCustom,
|
||||||
|
latest: false
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
version.partial.push(...this.inputs.tagCustom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
version.partial = version.partial.filter((item, index) => version.partial.indexOf(item) === index);
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public tags(): Array<string> {
|
public tags(): Array<string> {
|
||||||
const version: Version = this.version();
|
if (!this.version.main) {
|
||||||
if (!version.version) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
let tags: Array<string> = [];
|
let tags: Array<string> = [];
|
||||||
for (const image of this.inputs.images) {
|
for (const image of this.inputs.images) {
|
||||||
tags.push(`${image}:${version.version}`);
|
const imageLc = image.toLowerCase();
|
||||||
if (version.latest) {
|
tags.push(`${imageLc}:${this.version.main}`);
|
||||||
tags.push(`${image}:latest`);
|
for (const partial of this.version.partial) {
|
||||||
|
tags.push(`${imageLc}:${partial}`);
|
||||||
|
}
|
||||||
|
if (this.version.latest) {
|
||||||
|
tags.push(`${imageLc}:latest`);
|
||||||
}
|
}
|
||||||
if (this.context.sha && this.inputs.tagSha) {
|
if (this.context.sha && this.inputs.tagSha) {
|
||||||
tags.push(`${image}:sha-${this.context.sha.substr(0, 7)}`);
|
tags.push(`${imageLc}:sha-${this.context.sha.substr(0, 7)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tags;
|
return tags;
|
||||||
@@ -92,7 +135,7 @@ export class Meta {
|
|||||||
`org.opencontainers.image.description=${this.repo.description || ''}`,
|
`org.opencontainers.image.description=${this.repo.description || ''}`,
|
||||||
`org.opencontainers.image.url=${this.repo.html_url || ''}`,
|
`org.opencontainers.image.url=${this.repo.html_url || ''}`,
|
||||||
`org.opencontainers.image.source=${this.repo.html_url || ''}`,
|
`org.opencontainers.image.source=${this.repo.html_url || ''}`,
|
||||||
`org.opencontainers.image.version=${this.version().version || ''}`,
|
`org.opencontainers.image.version=${this.version.main || ''}`,
|
||||||
`org.opencontainers.image.created=${this.date.toISOString()}`,
|
`org.opencontainers.image.created=${this.date.toISOString()}`,
|
||||||
`org.opencontainers.image.revision=${this.context.sha || ''}`,
|
`org.opencontainers.image.revision=${this.context.sha || ''}`,
|
||||||
`org.opencontainers.image.licenses=${this.repo.license?.spdx_id || ''}`
|
`org.opencontainers.image.licenses=${this.repo.license?.spdx_id || ''}`
|
||||||
|
22
yarn.lock
22
yarn.lock
@@ -2545,6 +2545,13 @@ lodash@^4.17.19:
|
|||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
|
||||||
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
|
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
|
||||||
|
|
||||||
|
lru-cache@^6.0.0:
|
||||||
|
version "6.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
|
||||||
|
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
|
||||||
|
dependencies:
|
||||||
|
yallist "^4.0.0"
|
||||||
|
|
||||||
make-dir@^3.0.0:
|
make-dir@^3.0.0:
|
||||||
version "3.1.0"
|
version "3.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
|
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
|
||||||
@@ -3163,10 +3170,12 @@ saxes@^5.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
|
||||||
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
|
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
|
||||||
|
|
||||||
semver@7.x, semver@^7.3.2:
|
semver@7.x, semver@^7.3.2, semver@^7.3.4:
|
||||||
version "7.3.2"
|
version "7.3.4"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97"
|
||||||
integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==
|
integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==
|
||||||
|
dependencies:
|
||||||
|
lru-cache "^6.0.0"
|
||||||
|
|
||||||
semver@^6.0.0, semver@^6.3.0:
|
semver@^6.0.0, semver@^6.3.0:
|
||||||
version "6.3.0"
|
version "6.3.0"
|
||||||
@@ -3808,6 +3817,11 @@ y18n@^4.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
|
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
|
||||||
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==
|
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==
|
||||||
|
|
||||||
|
yallist@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
|
||||||
|
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
|
||||||
|
|
||||||
yargs-parser@20.x:
|
yargs-parser@20.x:
|
||||||
version "20.2.3"
|
version "20.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.3.tgz#92419ba867b858c868acf8bae9bf74af0dd0ce26"
|
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.3.tgz#92419ba867b858c868acf8bae9bf74af0dd0ce26"
|
||||||
|
Reference in New Issue
Block a user