Compare commits
59 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
05d22bf317 | ||
|
70b403b46b | ||
|
9e6ae02878 | ||
|
3d239e8b8a | ||
|
7cb52e2750 | ||
|
90a1d5cf21 | ||
|
c98ac5e987 | ||
|
44d853bc0a | ||
|
d1abf80723 | ||
|
3358a27538 | ||
|
314ddf6d4a | ||
|
b91e8f52b0 | ||
|
fbac5f9bca | ||
|
57396166ad | ||
|
473bdc561c | ||
|
ebedea2c18 | ||
|
d00b20e38f | ||
|
a99e71cdc7 | ||
|
12cce9efe0 | ||
|
f17e188860 | ||
|
210d783f42 | ||
|
5f26473e44 | ||
|
49e79e3532 | ||
|
5ebec4fd21 | ||
|
8ed470c7f1 | ||
|
61ddee1921 | ||
|
8671a4f8ec | ||
|
3862a1b70f | ||
|
f7c31b1e79 | ||
|
55b0d953e7 | ||
|
4c6a2cafd0 | ||
|
6c51f019f8 | ||
|
5c9aa83b20 | ||
|
30af4d7327 | ||
|
594a555a35 | ||
|
7fa87ab51a | ||
|
02d1a10cce | ||
|
58061722cc | ||
|
1c9aacf050 | ||
|
1f87faac28 | ||
|
59bc9ddfd5 | ||
|
286660a061 | ||
|
139c7584e2 | ||
|
ee266832e5 | ||
|
ae052be62f | ||
|
98045504c7 | ||
|
97c170d70b | ||
|
44ecceaf69 | ||
|
e4d14b2070 | ||
|
f66710ef6c | ||
|
d6cc766711 | ||
|
9c37b1c855 | ||
|
e518b0e7bb | ||
|
7bf589e898 | ||
|
bc6cb60a8a | ||
|
4db6eea5ea | ||
|
b5ee2f25f6 | ||
|
8d56fe93cf | ||
|
59267481d9 |
40
.github/workflows/ci.yml
vendored
40
.github/workflows/ci.yml
vendored
@@ -254,15 +254,15 @@ jobs:
|
||||
type=sha
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
driver-opts: network=host
|
||||
-
|
||||
name: Build and push to local registry
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: ./test
|
||||
file: ./test/Dockerfile
|
||||
@@ -309,16 +309,44 @@ jobs:
|
||||
type=sha
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Build
|
||||
uses: docker/bake-action@v1
|
||||
uses: docker/bake-action@v2
|
||||
with:
|
||||
files: |
|
||||
./test/docker-bake.hcl
|
||||
${{ steps.docker_meta.outputs.bake-file }}
|
||||
targets: |
|
||||
release
|
||||
|
||||
sep-tags:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sep:
|
||||
- " "
|
||||
- ","
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: ./
|
||||
with:
|
||||
images: |
|
||||
${{ env.DOCKER_IMAGE }}
|
||||
ghcr.io/name/app
|
||||
sep-tags: ${{ matrix.sep }}
|
||||
-
|
||||
name: Tags
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
console.log(`${{ steps.meta.outputs.tags }}`);
|
||||
|
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -19,12 +19,12 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Validate
|
||||
uses: docker/bake-action@v1
|
||||
uses: docker/bake-action@v2
|
||||
with:
|
||||
targets: validate
|
||||
-
|
||||
name: Test
|
||||
uses: docker/bake-action@v1
|
||||
uses: docker/bake-action@v2
|
||||
with:
|
||||
targets: test
|
||||
-
|
||||
|
248
README.md
248
README.md
@@ -1,12 +1,14 @@
|
||||
[](https://github.com/docker/metadata-action/releases/latest)
|
||||
[](https://github.com/marketplace/actions/docker-metadata-action)
|
||||
[](https://github.com/docker/metadata-action/actions?workflow=test)
|
||||
[](https://github.com/docker/metadata-action/actions?workflow=ci)
|
||||
[](https://github.com/docker/metadata-action/actions?workflow=test)
|
||||
[](https://codecov.io/gh/docker/metadata-action)
|
||||
|
||||
## About
|
||||
|
||||
GitHub Action to extract metadata from Git reference and GitHub events.
|
||||
This action is particularly useful if used with [Docker Build Push](https://github.com/docker/build-push-action) action to tag and label Docker images.
|
||||
GitHub Action to extract metadata from Git reference and GitHub events. This action
|
||||
is particularly useful if used with [Docker Build Push](https://github.com/docker/build-push-action)
|
||||
action to tag and label Docker images.
|
||||
|
||||

|
||||
|
||||
@@ -19,6 +21,7 @@ ___
|
||||
* [Customizing](#customizing)
|
||||
* [inputs](#inputs)
|
||||
* [outputs](#outputs)
|
||||
* [environment variables](#environment-variables)
|
||||
* [`images` input](#images-input)
|
||||
* [`flavor` input](#flavor-input)
|
||||
* [`tags` input](#tags-input)
|
||||
@@ -33,17 +36,18 @@ ___
|
||||
* [Notes](#notes)
|
||||
* [Image name and tag sanitization](#image-name-and-tag-sanitization)
|
||||
* [Latest tag](#latest-tag)
|
||||
* [`priority` attribute](#priority-attribute)
|
||||
* [Global expressions](#global-expressions)
|
||||
* [`{{branch}}`](#branch)
|
||||
* [`{{tag}}`](#tag)
|
||||
* [`{{sha}}`](#sha)
|
||||
* [`{{base_ref}}`](#base_ref)
|
||||
* [`{{is_default_branch}}`](#is_default_branch)
|
||||
* [`{{date '<format>'}}`](#date-format)
|
||||
* [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone)
|
||||
* [Major version zero](#major-version-zero)
|
||||
* [JSON output object](#json-output-object)
|
||||
* [Overwrite labels](#overwrite-labels)
|
||||
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
|
||||
* [Contributing](#contributing)
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -53,6 +57,7 @@ ___
|
||||
name: ci
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
@@ -68,7 +73,7 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
@@ -78,13 +83,13 @@ jobs:
|
||||
-
|
||||
name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
@@ -92,13 +97,14 @@ jobs:
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
```
|
||||
|
||||
| Event | Ref | Docker Tags |
|
||||
|-----------------|-------------------------------|-------------------------------------|
|
||||
| `pull_request` | `refs/pull/2/merge` | `pr-2` |
|
||||
| `push` | `refs/heads/master` | `master` |
|
||||
| `push` | `refs/heads/releases/v1` | `releases-v1` |
|
||||
| `push tag` | `refs/tags/v1.2.3` | `v1.2.3`, `latest` |
|
||||
| `push tag` | `refs/tags/v2.0.8-beta.67` | `v2.0.8-beta.67`, `latest` |
|
||||
| Event | Ref | Docker Tags |
|
||||
|---------------------|-------------------------------|----------------------------|
|
||||
| `pull_request` | `refs/pull/2/merge` | `pr-2` |
|
||||
| `push` | `refs/heads/master` | `master` |
|
||||
| `push` | `refs/heads/releases/v1` | `releases-v1` |
|
||||
| `push tag` | `refs/tags/v1.2.3` | `v1.2.3`, `latest` |
|
||||
| `push tag` | `refs/tags/v2.0.8-beta.67` | `v2.0.8-beta.67`, `latest` |
|
||||
| `workflow_dispatch` | `refs/heads/master` | `master` |
|
||||
|
||||
### Semver
|
||||
|
||||
@@ -121,7 +127,7 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
@@ -137,13 +143,13 @@ jobs:
|
||||
-
|
||||
name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
@@ -162,8 +168,8 @@ jobs:
|
||||
### Bake definition
|
||||
|
||||
This action also handles a bake definition file that can be used with the
|
||||
[Docker Bake action](https://github.com/docker/bake-action). You just have to declare an empty target named
|
||||
`docker-metadata-action` and inherit from it.
|
||||
[Docker Bake action](https://github.com/docker/bake-action). You just have to
|
||||
declare an empty target named `docker-metadata-action` and inherit from it.
|
||||
|
||||
```hcl
|
||||
// docker-bake.hcl
|
||||
@@ -199,7 +205,7 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
@@ -215,7 +221,7 @@ jobs:
|
||||
type=sha
|
||||
-
|
||||
name: Build
|
||||
uses: docker/bake-action@v1
|
||||
uses: docker/bake-action@v2
|
||||
with:
|
||||
files: |
|
||||
./docker-bake.hcl
|
||||
@@ -223,7 +229,8 @@ jobs:
|
||||
targets: build
|
||||
```
|
||||
|
||||
Content of `${{ steps.meta.outputs.bake-file }}` file will look like this with `refs/tags/v1.2.3` ref:
|
||||
Content of `${{ steps.meta.outputs.bake-file }}` file will look like this with
|
||||
`refs/tags/v1.2.3` ref:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -282,13 +289,19 @@ Following inputs can be used as `step.with` keys
|
||||
|
||||
Following outputs are available
|
||||
|
||||
| Name | Type | Description |
|
||||
|---------------|---------|-------------------------------------------------------------------------------|
|
||||
| `version` | String | Docker image version |
|
||||
| `tags` | String | Docker tags |
|
||||
| `labels` | String | Docker labels |
|
||||
| `json` | String | JSON output of tags and labels |
|
||||
| `bake-file` | File | [Bake definition file](https://github.com/docker/buildx#file-definition) path |
|
||||
| Name | Type | Description |
|
||||
|---------------|---------|--------------------------------------------------------------------------------------------|
|
||||
| `version` | String | Docker image version |
|
||||
| `tags` | String | Docker tags |
|
||||
| `labels` | String | Docker labels |
|
||||
| `json` | String | JSON output of tags and labels |
|
||||
| `bake-file` | File | [Bake file definition](https://docs.docker.com/build/customize/bake/file-definition/) path |
|
||||
|
||||
### environment variables
|
||||
|
||||
| Name | Type | Description |
|
||||
|-------------------------------|------|------------------------------------------------------------------------------------------------------------|
|
||||
| `DOCKER_METADATA_PR_HEAD_SHA` | Bool | If `true`, set associated head SHA instead of commit SHA that triggered the workflow on pull request event |
|
||||
|
||||
## `images` input
|
||||
|
||||
@@ -325,13 +338,16 @@ flavor: |
|
||||
```
|
||||
|
||||
* `latest=<auto|true|false>`: Handle [latest tag](#latest-tag) (default `auto`)
|
||||
* `prefix=<string>,onlatest=<true|false>`: A global prefix for each generated tag and optionally for `latest`
|
||||
* `suffix=<string>,onlatest=<true|false>`: A global suffix for each generated tag and optionally for `latest`
|
||||
* `prefix=<string>,onlatest=<true|false>`: A global prefix for each generated
|
||||
tag and optionally for `latest`
|
||||
* `suffix=<string>,onlatest=<true|false>`: A global suffix for each generated
|
||||
tag and optionally for `latest`
|
||||
|
||||
## `tags` input
|
||||
|
||||
`tags` is the core input of this action as everything related to it will reflect the output metadata. This one is in
|
||||
the form of a key-value pair list in CSV format to remove limitations intrinsically linked to GitHub Actions
|
||||
`tags` is the core input of this action as everything related to it will
|
||||
reflect the output metadata. This one is in the form of a key-value pair list
|
||||
in CSV format to remove limitations intrinsically linked to GitHub Actions
|
||||
(only string format is handled in the input fields). Here is an example:
|
||||
|
||||
```yaml
|
||||
@@ -359,7 +375,7 @@ Each entry is defined by a `type`, which are:
|
||||
And global attributes:
|
||||
|
||||
* `enable=<true|false>` enable this entry (default `true`)
|
||||
* `priority=<number>` priority to manage the order of tags
|
||||
* `priority=<number>` set tag [priority](#priority-attribute) order
|
||||
* `prefix=<string>` add prefix
|
||||
* `suffix=<string>` add suffix
|
||||
|
||||
@@ -383,18 +399,23 @@ tags: |
|
||||
type=schedule,pattern=nightly
|
||||
# handlebars
|
||||
type=schedule,pattern={{date 'YYYYMMDD'}}
|
||||
# handlebars with timezone
|
||||
type=schedule,pattern={{date 'YYYYMMDD-hhmmss' tz='Asia/Tokyo'}}
|
||||
```
|
||||
|
||||
Will be used on [schedule event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule).
|
||||
Will be used on [schedule event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule).
|
||||
|
||||
`pattern` is a specially crafted attribute to support [Handlebars' template](https://handlebarsjs.com/guide/) with
|
||||
the following expressions:
|
||||
* `date 'format'` ; render date by its [moment format](https://momentjs.com/docs/#/displaying/format/)
|
||||
`pattern` is a specially crafted attribute to support [Handlebars' template](https://handlebarsjs.com/guide/)
|
||||
with the following expressions:
|
||||
|
||||
| Pattern | Output |
|
||||
|--------------------------|----------------------|
|
||||
| `nightly` | `nightly` |
|
||||
| `{{date 'YYYYMMDD'}}` | `20210326` |
|
||||
* `date 'format' tz='Timezone'` ; render date by its [moment format](https://momentjs.com/docs/#/displaying/format/).
|
||||
Default `tz` is UTC.
|
||||
|
||||
| Pattern | Output |
|
||||
|----------------------------------------------|-------------------|
|
||||
| `nightly` | `nightly` |
|
||||
| `{{date 'YYYYMMDD'}}` | `20200110` |
|
||||
| `{{date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}` | `20200110-093000` |
|
||||
|
||||
Extended attributes and default values:
|
||||
|
||||
@@ -413,11 +434,13 @@ tags: |
|
||||
type=semver,pattern={{version}},value=v1.0.0
|
||||
```
|
||||
|
||||
Will be used on a [push tag event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#push)
|
||||
and requires a valid [semver](https://semver.org/) Git tag, but you can also use a custom value through `value`
|
||||
attribute.
|
||||
Will be used on a [push tag event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push)
|
||||
and requires a valid [semver](https://semver.org/) Git tag, but you can also
|
||||
use a custom value through `value` attribute.
|
||||
|
||||
`pattern` attribute supports [Handlebars template](https://handlebarsjs.com/guide/)
|
||||
with the following expressions:
|
||||
|
||||
`pattern` attribute supports [Handlebars template](https://handlebarsjs.com/guide/) with the following expressions:
|
||||
* `raw` ; the actual tag
|
||||
* `version` ; shorthand for `{{major}}.{{minor}}.{{patch}}` (can include pre-release)
|
||||
* `major` ; major version identifier
|
||||
@@ -436,9 +459,10 @@ attribute.
|
||||
| `v2.0.8-beta.67` | `{{version}}` | `2.0.8-beta.67` |
|
||||
| `v2.0.8-beta.67` | `{{major}}.{{minor}}` | `2.0.8-beta.67`* |
|
||||
|
||||
> *Pre-release (rc, beta, alpha) will only extend `{{version}}` (or `{{raw}}` if specified) 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.
|
||||
> *Pre-release (rc, beta, alpha) will only extend `{{version}}` (or `{{raw}}`
|
||||
> if specified) 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.
|
||||
|
||||
Extended attributes and default values:
|
||||
|
||||
@@ -457,11 +481,13 @@ tags: |
|
||||
type=pep440,pattern={{version}},value=1.0.0
|
||||
```
|
||||
|
||||
Will be used on a [push tag event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#push)
|
||||
and requires a Git tag that conforms to [PEP 440](https://www.python.org/dev/peps/pep-0440/), but you can also use a
|
||||
custom value through `value` attribute.
|
||||
Will be used on a [push tag event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push)
|
||||
and requires a Git tag that conforms to [PEP 440](https://www.python.org/dev/peps/pep-0440/),
|
||||
but you can also use a custom value through `value` attribute.
|
||||
|
||||
`pattern` attribute supports [Handlebars template](https://handlebarsjs.com/guide/)
|
||||
with the following expressions:
|
||||
|
||||
`pattern` attribute supports [Handlebars template](https://handlebarsjs.com/guide/) with the following expressions:
|
||||
* `raw` ; the actual tag
|
||||
* `version` ; cleaned version
|
||||
* `major` ; major version identifier
|
||||
@@ -482,9 +508,10 @@ custom value through `value` attribute.
|
||||
| `1.2.3beta2` | `{{major}}.{{minor}}` | `1.2.3b2`* |
|
||||
| `1.0dev4` | `{{major}}.{{minor}}` | `1.0.dev4`* |
|
||||
|
||||
> *dev/pre/post release will only extend `{{version}}` (or `{{raw}}` if specified) 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.
|
||||
> *dev/pre/post release will only extend `{{version}}` (or `{{raw}}` if
|
||||
> specified) 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.
|
||||
|
||||
Extended attributes and default values:
|
||||
|
||||
@@ -505,9 +532,9 @@ tags: |
|
||||
type=match,pattern=v(.*),group=1,value=v1.0.0
|
||||
```
|
||||
|
||||
Can create a regular expression for matching Git tag with a pattern and capturing group. Will be used on a
|
||||
[push tag event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#push) but, you can also use
|
||||
a custom value through `value` attribute.
|
||||
Can create a regular expression for matching Git tag with a pattern and
|
||||
capturing group. Will be used on a [push tag event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push)
|
||||
but, you can also use a custom value through `value` attribute.
|
||||
|
||||
| Git tag | Pattern | Group | Output |
|
||||
|-------------------------|------------------|---------|------------------------|
|
||||
@@ -534,9 +561,9 @@ tags: |
|
||||
type=edge,branch=main
|
||||
```
|
||||
|
||||
An `edge` tag reflects the last commit of the active branch on your Git repository. I usually prefer to use `edge`
|
||||
as a Docker tag for a better distinction or common pattern. This is also used by official images
|
||||
like [Alpine](https://hub.docker.com/_/alpine).
|
||||
An `edge` tag reflects the last commit of the active branch on your Git
|
||||
repository. I usually prefer to use `edge` as a Docker tag for a better
|
||||
distinction or common pattern. This is also used by official images like [Alpine](https://hub.docker.com/_/alpine).
|
||||
|
||||
Extended attributes and default values:
|
||||
|
||||
@@ -558,17 +585,19 @@ tags: |
|
||||
```
|
||||
|
||||
This type handles Git ref (or reference) for the following events:
|
||||
|
||||
* `branch` ; eg. `refs/heads/master`
|
||||
* `tag` ; eg. `refs/tags/v1.0.0`
|
||||
* `pr` ; eg. `refs/pull/318/merge`
|
||||
|
||||
| Event | Ref | Output |
|
||||
|-----------------|-------------------------------|-------------------------------|
|
||||
| `pull_request` | `refs/pull/2/merge` | `pr-2` |
|
||||
| `push` | `refs/heads/master` | `master` |
|
||||
| `push` | `refs/heads/my/branch` | `my-branch` |
|
||||
| `push tag` | `refs/tags/v1.2.3` | `v1.2.3` |
|
||||
| `push tag` | `refs/tags/v2.0.8-beta.67` | `v2.0.8-beta.67` |
|
||||
| Event | Ref | Output |
|
||||
|---------------------|-------------------------------|------------------|
|
||||
| `pull_request` | `refs/pull/2/merge` | `pr-2` |
|
||||
| `push` | `refs/heads/master` | `master` |
|
||||
| `push` | `refs/heads/my/branch` | `my-branch` |
|
||||
| `push tag` | `refs/tags/v1.2.3` | `v1.2.3` |
|
||||
| `push tag` | `refs/tags/v2.0.8-beta.67` | `v2.0.8-beta.67` |
|
||||
| `workflow_dispatch` | `refs/heads/master` | `master` |
|
||||
|
||||
Extended attributes and default values:
|
||||
|
||||
@@ -628,7 +657,7 @@ tags: |
|
||||
|
||||
### Image name and tag sanitization
|
||||
|
||||
In order to comply with [the specification](https://docs.docker.com/engine/reference/commandline/tag/#extended-description),
|
||||
In order to comply with [the specification](https://docs.docker.com/engine/reference/commandline/tag/#description),
|
||||
the image name components may contain lowercase letters, digits and separators.
|
||||
A separator is defined as a period, one or two underscores, or one or more
|
||||
dashes. A name component may not start or end with a separator.
|
||||
@@ -644,7 +673,9 @@ To ease the integration in your workflow, this action will automatically:
|
||||
|
||||
### Latest tag
|
||||
|
||||
`latest` tag is handled through the [`flavor` input](#flavor-input). It will be generated by default (`auto` mode) for:
|
||||
`latest` tag is handled through the [`flavor` input](#flavor-input). It will be
|
||||
generated by default (`auto` mode) for:
|
||||
|
||||
* [`type=ref,event=tag`](#typeref)
|
||||
* [`type=semver,pattern=...`](#typesemver)
|
||||
* [`type=match,pattern=...`](#typematch)
|
||||
@@ -667,6 +698,24 @@ tags: |
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
```
|
||||
|
||||
### `priority` attribute
|
||||
|
||||
`priority=<int>` attribute is used to sort tags in the final list. The higher
|
||||
the value, the higher the priority. The first tag in the list (higher priority)
|
||||
will be used as the image version for generated OCI label and [`version` output](#outputs).
|
||||
Each tags `type` attribute has a default priority:
|
||||
|
||||
| Attribute | Default priority |
|
||||
|------------|------------------|
|
||||
| `schedule` | `1000` |
|
||||
| `semver` | `900` |
|
||||
| `pep440` | `900` |
|
||||
| `match` | `800` |
|
||||
| `edge` | `700` |
|
||||
| `ref` | `600` |
|
||||
| `raw` | `200` |
|
||||
| `sha` | `100` |
|
||||
|
||||
### Global expressions
|
||||
|
||||
The following [Handlebars' template](https://handlebarsjs.com/guide/) expressions
|
||||
@@ -685,12 +734,12 @@ tags: |
|
||||
Returns the branch name that triggered the workflow run. Will be empty if not
|
||||
a branch reference:
|
||||
|
||||
| Event | Ref | Output |
|
||||
|-----------------|-------------------------------|---------------------|
|
||||
| `pull_request` | `refs/pull/2/merge` | |
|
||||
| `push` | `refs/heads/master` | `master` |
|
||||
| `push` | `refs/heads/my/branch` | `my-branch` |
|
||||
| `push tag` | `refs/tags/v1.2.3` | |
|
||||
| Event | Ref | Output |
|
||||
|----------------|------------------------|-------------|
|
||||
| `pull_request` | `refs/pull/2/merge` | |
|
||||
| `push` | `refs/heads/master` | `master` |
|
||||
| `push` | `refs/heads/my/branch` | `my-branch` |
|
||||
| `push tag` | `refs/tags/v1.2.3` | |
|
||||
|
||||
#### `{{tag}}`
|
||||
|
||||
@@ -731,22 +780,24 @@ workflow run. Will be empty for a branch reference:
|
||||
Returns `true` if the branch that triggered the workflow run is the default
|
||||
one, otherwise `false`.
|
||||
|
||||
#### `{{date '<format>'}}`
|
||||
#### `{{date '<format>' tz='<timezone>'}}`
|
||||
|
||||
Returns the current date rendered by its [moment format](https://momentjs.com/docs/#/displaying/format/).
|
||||
Default `tz` is UTC.
|
||||
|
||||
| Expression | Output example |
|
||||
|--------------------------------------------|-----------------------------------------|
|
||||
| `{{date 'YYYYMMDD'}}` | `20200110` |
|
||||
| `{{date 'dddd, MMMM Do YYYY, h:mm:ss a'}}` | `Friday, January 10th 2020, 3:25:50 pm` |
|
||||
| Expression | Output example |
|
||||
|----------------------------------------------|-----------------------------------------|
|
||||
| `{{date 'YYYYMMDD'}}` | `20200110` |
|
||||
| `{{date 'dddd, MMMM Do YYYY, h:mm:ss a'}}` | `Friday, January 10th 2020, 3:25:50 pm` |
|
||||
| `{{date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}` | `20200110-093000` |
|
||||
|
||||
### Major version zero
|
||||
|
||||
Major version zero (`0.y.z`) is for initial development and **may** change at any time. This means the public API
|
||||
[**should not** be considered stable](https://semver.org/#spec-item-4).
|
||||
Major version zero (`0.y.z`) is for initial development and **may** change at
|
||||
any time. This means the public API [**should not** be considered stable](https://semver.org/#spec-item-4).
|
||||
|
||||
In this case, Docker tag `0` **should not** be generated if you're using [`type=semver`](#typesemver) with `{{major}}`
|
||||
pattern. You can manage this behavior like this:
|
||||
In this case, Docker tag `0` **should not** be generated if you're using [`type=semver`](#typesemver)
|
||||
with `{{major}}` pattern. You can manage this behavior like this:
|
||||
|
||||
```yaml
|
||||
# refs/tags/v0.1.2
|
||||
@@ -761,8 +812,8 @@ tags: |
|
||||
|
||||
### JSON output object
|
||||
|
||||
The `json` output is a JSON object composed of the generated tags and labels so that you can reuse them further in your
|
||||
workflow using the [`fromJSON` function](https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson):
|
||||
The `json` output is a JSON object composed of the generated tags and labels so
|
||||
that you can reuse them further in your workflow using the [`fromJSON` function](https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson):
|
||||
|
||||
```yaml
|
||||
-
|
||||
@@ -773,7 +824,7 @@ workflow using the [`fromJSON` function](https://docs.github.com/en/actions/lear
|
||||
images: name/app
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
@@ -802,18 +853,7 @@ labels generated are not suitable, you can overwrite them like this:
|
||||
org.opencontainers.image.vendor=MyCompany
|
||||
```
|
||||
|
||||
## Keep up-to-date with GitHub Dependabot
|
||||
## Contributing
|
||||
|
||||
Since [Dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot)
|
||||
has [native GitHub Actions support](https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#package-ecosystem),
|
||||
to enable it on your GitHub repo all you need to do is add the `.github/dependabot.yml` file:
|
||||
|
||||
```yaml
|
||||
version: 2
|
||||
updates:
|
||||
# Maintain dependencies for GitHub Actions
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
```
|
||||
Want to contribute? Awesome! You can find information about contributing to
|
||||
this project in the [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
|
||||
|
27
UPGRADE.md
27
UPGRADE.md
@@ -2,7 +2,8 @@
|
||||
|
||||
## v2 to v3
|
||||
|
||||
* Repository has been moved to docker org. Replace `crazy-max/ghaction-docker-meta@v2` with `docker/metadata-action@v4`
|
||||
* Repository has been moved to docker org. Replace `crazy-max/ghaction-docker-meta@v2`
|
||||
with `docker/metadata-action@v4`
|
||||
* The default bake target has been changed: `ghaction-docker-meta` > `docker-metadata-action`
|
||||
|
||||
## v1 to v2
|
||||
@@ -132,7 +133,7 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
@@ -142,13 +143,13 @@ jobs:
|
||||
-
|
||||
name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
@@ -176,7 +177,7 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
@@ -186,13 +187,13 @@ jobs:
|
||||
-
|
||||
name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
@@ -222,7 +223,7 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
@@ -235,13 +236,13 @@ jobs:
|
||||
-
|
||||
name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
@@ -269,7 +270,7 @@ jobs:
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
@@ -284,13 +285,13 @@ jobs:
|
||||
-
|
||||
name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import {beforeEach, describe, expect, it, jest} from '@jest/globals';
|
||||
import {describe, expect, it, jest} from '@jest/globals';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
|
||||
import * as context from '../src/context';
|
||||
@@ -166,30 +165,6 @@ describe('asyncForEach', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('setOutput', () => {
|
||||
beforeEach(() => {
|
||||
process.stdout.write = jest.fn() as typeof process.stdout.write;
|
||||
});
|
||||
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
it('setOutput produces the correct command', () => {
|
||||
context.setOutput('some output', 'some value');
|
||||
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
it('setOutput handles bools', () => {
|
||||
context.setOutput('some output', false);
|
||||
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
it('setOutput handles numbers', () => {
|
||||
context.setOutput('some output', 1.01);
|
||||
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
|
||||
});
|
||||
});
|
||||
|
||||
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
||||
function getInputName(name: string): string {
|
||||
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||
@@ -198,11 +173,3 @@ function getInputName(name: string): string {
|
||||
function setInput(name: string, value: string): void {
|
||||
process.env[getInputName(name)] = value;
|
||||
}
|
||||
|
||||
// Assert that process.stdout.write calls called only with the given arguments.
|
||||
function assertWriteCalls(calls: string[]): void {
|
||||
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
|
||||
for (let i = 0; i < calls.length; i++) {
|
||||
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as dotenv from 'dotenv';
|
||||
import * as moment from 'moment';
|
||||
import moment from 'moment-timezone';
|
||||
import {getInputs, Inputs} from '../src/context';
|
||||
import * as github from '../src/github';
|
||||
import {Meta, Version} from '../src/meta';
|
||||
@@ -21,8 +21,8 @@ jest.spyOn(global.Date.prototype, 'toISOString').mockImplementation(() => {
|
||||
return '2020-01-10T00:30:00.000Z';
|
||||
});
|
||||
|
||||
jest.mock('moment', () => {
|
||||
return () => (jest.requireActual('moment') as typeof import('moment'))('2020-01-10T00:30:00.000Z');
|
||||
jest.mock('moment-timezone', () => {
|
||||
return () => (jest.requireActual('moment-timezone') as typeof import('moment-timezone'))('2020-01-10T00:30:00.000Z');
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -65,6 +65,7 @@ const tagsLabelsTest = async (name: string, envFile: string, inputs: Inputs, exV
|
||||
|
||||
describe('null', () => {
|
||||
// prettier-ignore
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
test.each([
|
||||
[
|
||||
'null01',
|
||||
@@ -121,6 +122,7 @@ describe('null', () => {
|
||||
|
||||
describe('push', () => {
|
||||
// prettier-ignore
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
test.each([
|
||||
[
|
||||
'push01',
|
||||
@@ -597,6 +599,7 @@ describe('push', () => {
|
||||
tags: [
|
||||
`type=raw,value=mytag-{{branch}}`,
|
||||
`type=raw,value=mytag-{{date 'YYYYMMDD'}}`,
|
||||
`type=raw,value=mytag-{{date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}`,
|
||||
`type=raw,value=mytag-tag-{{tag}}`,
|
||||
`type=raw,value=mytag-baseref-{{base_ref}}`,
|
||||
`type=raw,value=mytag-defbranch,enable={{is_default_branch}}`
|
||||
@@ -606,6 +609,7 @@ describe('push', () => {
|
||||
main: 'mytag-master',
|
||||
partial: [
|
||||
'mytag-20200110',
|
||||
'mytag-20200110-093000',
|
||||
'mytag-tag-',
|
||||
'mytag-baseref-',
|
||||
'mytag-defbranch'
|
||||
@@ -615,6 +619,7 @@ describe('push', () => {
|
||||
[
|
||||
'user/app:mytag-master',
|
||||
'user/app:mytag-20200110',
|
||||
'user/app:mytag-20200110-093000',
|
||||
'user/app:mytag-tag-',
|
||||
'user/app:mytag-baseref-',
|
||||
'user/app:mytag-defbranch'
|
||||
@@ -732,6 +737,7 @@ describe('push', () => {
|
||||
|
||||
describe('tag', () => {
|
||||
// prettier-ignore
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
test.each([
|
||||
[
|
||||
'tag01',
|
||||
@@ -1777,6 +1783,7 @@ describe('tag', () => {
|
||||
|
||||
describe('latest', () => {
|
||||
// prettier-ignore
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
test.each([
|
||||
[
|
||||
'latest01',
|
||||
@@ -2064,6 +2071,7 @@ describe('latest', () => {
|
||||
|
||||
describe('pr', () => {
|
||||
// prettier-ignore
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
test.each([
|
||||
[
|
||||
'pr01',
|
||||
@@ -2409,8 +2417,373 @@ describe('pr', () => {
|
||||
])('given %p with %p event', tagsLabelsTest);
|
||||
});
|
||||
|
||||
describe('pr-head-sha', () => {
|
||||
// prettier-ignore
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
test.each([
|
||||
[
|
||||
'pr01',
|
||||
'event_pull_request.env',
|
||||
{
|
||||
images: ['user/app'],
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'pr-15',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'user/app:pr-15'
|
||||
],
|
||||
[
|
||||
"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=pr-15",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=3370e228f2209994d57af4427fe64e71bb79ac96",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr02',
|
||||
'event_pull_request.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'pr-15',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:pr-15',
|
||||
'ghcr.io/user/app:pr-15'
|
||||
],
|
||||
[
|
||||
"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=pr-15",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=3370e228f2209994d57af4427fe64e71bb79ac96",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr03',
|
||||
'event_pull_request.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=ref,event=pr`,
|
||||
`type=sha`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'pr-15',
|
||||
partial: ['sha-3370e22'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:pr-15',
|
||||
'org/app:sha-3370e22',
|
||||
'ghcr.io/user/app:pr-15',
|
||||
'ghcr.io/user/app:sha-3370e22'
|
||||
],
|
||||
[
|
||||
"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=pr-15",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=3370e228f2209994d57af4427fe64e71bb79ac96",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr04',
|
||||
'event_pull_request.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=sha,priority=2000`,
|
||||
`type=ref,event=pr`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'sha-3370e22',
|
||||
partial: ['pr-15'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:sha-3370e22',
|
||||
'org/app:pr-15',
|
||||
'ghcr.io/user/app:sha-3370e22',
|
||||
'ghcr.io/user/app:pr-15'
|
||||
],
|
||||
[
|
||||
"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=sha-3370e22",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=3370e228f2209994d57af4427fe64e71bb79ac96",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr05',
|
||||
'event_pull_request.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=ref,event=pr`
|
||||
],
|
||||
flavor: [
|
||||
`prefix=glo-`,
|
||||
`suffix=-bal`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'pr-15-bal',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:pr-15-bal',
|
||||
'ghcr.io/user/app:pr-15-bal'
|
||||
],
|
||||
[
|
||||
"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=pr-15-bal",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=3370e228f2209994d57af4427fe64e71bb79ac96",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr06',
|
||||
'event_pull_request.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=ref,event=pr,prefix=`
|
||||
],
|
||||
flavor: [
|
||||
`prefix=glo-`,
|
||||
`suffix=-bal`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: '15-bal',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:15-bal',
|
||||
'ghcr.io/user/app:15-bal'
|
||||
],
|
||||
[
|
||||
"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=15-bal",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=3370e228f2209994d57af4427fe64e71bb79ac96",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr07',
|
||||
'event_pull_request_target.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=sha,priority=2000`,
|
||||
`type=ref,event=pr`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'sha-3370e22',
|
||||
partial: ['pr-15'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:sha-3370e22',
|
||||
'org/app:pr-15',
|
||||
'ghcr.io/user/app:sha-3370e22',
|
||||
'ghcr.io/user/app:pr-15'
|
||||
],
|
||||
[
|
||||
"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=sha-3370e22",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=3370e228f2209994d57af4427fe64e71bb79ac96",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr08',
|
||||
'event_pull_request_target.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=ref,event=pr,prefix=`
|
||||
],
|
||||
flavor: [
|
||||
`prefix=glo-`,
|
||||
`suffix=-bal`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: '15-bal',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:15-bal',
|
||||
'ghcr.io/user/app:15-bal'
|
||||
],
|
||||
[
|
||||
"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=15-bal",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=3370e228f2209994d57af4427fe64e71bb79ac96",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr09',
|
||||
'event_pull_request_target.env',
|
||||
{
|
||||
images: ['org/app'],
|
||||
tags: [
|
||||
`type=ref,event=tag`,
|
||||
`type=ref,event=pr`,
|
||||
`type=ref,event=branch`,
|
||||
`type=sha`,
|
||||
`type=sha,format=long`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'pr-15',
|
||||
partial: [
|
||||
'sha-3370e22',
|
||||
'sha-3370e228f2209994d57af4427fe64e71bb79ac96'
|
||||
],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:pr-15',
|
||||
'org/app:sha-3370e22',
|
||||
'org/app:sha-3370e228f2209994d57af4427fe64e71bb79ac96'
|
||||
],
|
||||
[
|
||||
"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=pr-15",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=3370e228f2209994d57af4427fe64e71bb79ac96",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr10',
|
||||
'event_pull_request_target.env',
|
||||
{
|
||||
images: ['org/app'],
|
||||
tags: [
|
||||
`type=raw,value=mytag-{{base_ref}}`,
|
||||
`type=raw,mytag-defbranch,enable={{is_default_branch}}`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'mytag-master',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:mytag-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",
|
||||
"org.opencontainers.image.version=mytag-master",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=3370e228f2209994d57af4427fe64e71bb79ac96",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr11',
|
||||
'event_pull_request.env',
|
||||
{
|
||||
images: ['org/app'],
|
||||
tags: [
|
||||
`type=raw,value=mytag-{{base_ref}}`,
|
||||
`type=raw,mytag-defbranch,enable={{is_default_branch}}`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'mytag-master',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:mytag-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",
|
||||
"org.opencontainers.image.version=mytag-master",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=3370e228f2209994d57af4427fe64e71bb79ac96",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
])('given %p with %p event', async (name: string, envFile: string, inputs: Inputs, exVersion: Version, exTags: Array<string>, exLabels: Array<string>) => {
|
||||
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
||||
process.env.DOCKER_METADATA_PR_HEAD_SHA = 'true';
|
||||
const context = github.context();
|
||||
|
||||
const repo = await github.repo(process.env.GITHUB_TOKEN || '');
|
||||
const meta = new Meta({...getInputs(), ...inputs}, context, repo);
|
||||
|
||||
const version = meta.version;
|
||||
expect(version).toEqual(exVersion);
|
||||
|
||||
const tags = meta.getTags();
|
||||
expect(tags).toEqual(exTags);
|
||||
|
||||
const labels = meta.getLabels();
|
||||
expect(labels).toEqual(exLabels);
|
||||
});
|
||||
});
|
||||
|
||||
describe('schedule', () => {
|
||||
// prettier-ignore
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
test.each([
|
||||
[
|
||||
'schedule01',
|
||||
@@ -2625,11 +2998,40 @@ describe('schedule', () => {
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'schedule08',
|
||||
'event_schedule.env',
|
||||
{
|
||||
images: ['user/app'],
|
||||
tags: [
|
||||
`type=schedule,pattern={{date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: '20200110-093000',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'user/app:20200110-093000'
|
||||
],
|
||||
[
|
||||
"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-093000",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
])('given %p with %p event', tagsLabelsTest);
|
||||
});
|
||||
|
||||
describe('release', () => {
|
||||
// prettier-ignore
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
test.each([
|
||||
[
|
||||
'release01',
|
||||
@@ -2696,6 +3098,7 @@ describe('release', () => {
|
||||
|
||||
describe('raw', () => {
|
||||
// prettier-ignore
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
test.each([
|
||||
[
|
||||
'raw01',
|
||||
@@ -3065,6 +3468,7 @@ describe('raw', () => {
|
||||
|
||||
describe('json', () => {
|
||||
// prettier-ignore
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
test.each([
|
||||
[
|
||||
'json01',
|
||||
@@ -3315,6 +3719,7 @@ describe('json', () => {
|
||||
|
||||
describe('bake', () => {
|
||||
// prettier-ignore
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
test.each([
|
||||
[
|
||||
'bake01',
|
||||
@@ -3617,3 +4022,48 @@ describe('bake', () => {
|
||||
expect(JSON.parse(fs.readFileSync(bakeFile, 'utf8'))).toEqual(exBakeDefinition);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sepTags', () => {
|
||||
// prettier-ignore
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
test.each([
|
||||
[
|
||||
'sepTags01',
|
||||
'event_push_dev.env',
|
||||
{
|
||||
images: ['user/app'],
|
||||
tags: [
|
||||
`type=ref,event=branch`,
|
||||
`type=raw,my`,
|
||||
`type=raw,custom`,
|
||||
`type=raw,tags`
|
||||
],
|
||||
sepTags: " "
|
||||
} as Inputs,
|
||||
"user/app:dev user/app:my user/app:custom user/app:tags"
|
||||
],
|
||||
[
|
||||
'sepTags02',
|
||||
'event_push_dev.env',
|
||||
{
|
||||
images: ['user/app'],
|
||||
tags: [
|
||||
`type=ref,event=branch`,
|
||||
`type=raw,my`,
|
||||
`type=raw,custom`,
|
||||
`type=raw,tags`
|
||||
],
|
||||
sepTags: ","
|
||||
} as Inputs,
|
||||
"user/app:dev,user/app:my,user/app:custom,user/app:tags"
|
||||
]
|
||||
])('given %p with %p event', async (name: string, envFile: string, inputs: Inputs, expTags: string) => {
|
||||
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
||||
const context = github.context();
|
||||
|
||||
const repo = await github.repo(process.env.GITHUB_TOKEN || '');
|
||||
const meta = new Meta({...getInputs(), ...inputs}, context, repo);
|
||||
|
||||
expect(meta.getTags().join(inputs.sepTags)).toEqual(expTags);
|
||||
});
|
||||
});
|
||||
|
@@ -126,6 +126,18 @@ describe('parse', () => {
|
||||
} as Tag,
|
||||
false
|
||||
],
|
||||
[
|
||||
`type=schedule,enable=true,pattern={{date 'YYYYMMDD' tz='Asia/Tokyo'}}`,
|
||||
{
|
||||
type: Type.Schedule,
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Schedule],
|
||||
"enable": "true",
|
||||
"pattern": `{{date 'YYYYMMDD' tz='Asia/Tokyo'}}`
|
||||
}
|
||||
} as Tag,
|
||||
false
|
||||
],
|
||||
[
|
||||
`type=semver,enable=true,pattern={{version}}`,
|
||||
{
|
||||
|
32
dist/index.js
generated
vendored
32
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
36
dist/licenses.txt
generated
vendored
36
dist/licenses.txt
generated
vendored
@@ -627,6 +627,29 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
moment-timezone
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) JS Foundation and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
node-fetch
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
@@ -762,6 +785,19 @@ Permission to use, copy, modify, and/or distribute this software for any purpose
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
uuid
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
webidl-conversions
|
||||
BSD-2-Clause
|
||||
# The BSD 2-Clause License
|
||||
|
@@ -29,12 +29,13 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.6.0",
|
||||
"@actions/github": "^5.0.1",
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/github": "^5.1.1",
|
||||
"@renovate/pep440": "^1.0.0",
|
||||
"csv-parse": "^5.0.4",
|
||||
"csv-parse": "^5.3.3",
|
||||
"handlebars": "^4.7.7",
|
||||
"moment": "^2.29.3",
|
||||
"moment": "^2.29.4",
|
||||
"moment-timezone": "^0.5.40",
|
||||
"semver": "^7.3.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@@ -1,9 +1,8 @@
|
||||
import {parse} from 'csv-parse/sync';
|
||||
import * as core from '@actions/core';
|
||||
import {issueCommand} from '@actions/core/lib/command';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
import {parse} from 'csv-parse/sync';
|
||||
|
||||
let _tmpDir: string;
|
||||
|
||||
@@ -31,8 +30,8 @@ export function getInputs(): Inputs {
|
||||
tags: getInputList('tags', true),
|
||||
flavor: getInputList('flavor', true),
|
||||
labels: getInputList('labels', true),
|
||||
sepTags: core.getInput('sep-tags') || `\n`,
|
||||
sepLabels: core.getInput('sep-labels') || `\n`,
|
||||
sepTags: core.getInput('sep-tags', {trimWhitespace: false}) || `\n`,
|
||||
sepLabels: core.getInput('sep-labels', {trimWhitespace: false}) || `\n`,
|
||||
bakeTarget: core.getInput('bake-target') || `docker-metadata-action`,
|
||||
githubToken: core.getInput('github-token')
|
||||
};
|
||||
@@ -73,8 +72,3 @@ export const asyncForEach = async (array, callback) => {
|
||||
await callback(array[index], index, array);
|
||||
}
|
||||
};
|
||||
|
||||
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
||||
export function setOutput(name: string, value: unknown): void {
|
||||
issueCommand('set-output', {name}, value);
|
||||
}
|
||||
|
16
src/main.ts
16
src/main.ts
@@ -1,5 +1,5 @@
|
||||
import * as fs from 'fs';
|
||||
import {getInputs, Inputs, setOutput} from './context';
|
||||
import {getInputs, Inputs} from './context';
|
||||
import * as github from './github';
|
||||
import {Meta, Version} from './meta';
|
||||
import * as core from '@actions/core';
|
||||
@@ -41,7 +41,7 @@ async function run() {
|
||||
core.info(version.main || '');
|
||||
core.endGroup();
|
||||
}
|
||||
setOutput('version', version.main || '');
|
||||
core.setOutput('version', version.main || '');
|
||||
|
||||
// Docker tags
|
||||
const tags: Array<string> = meta.getTags();
|
||||
@@ -54,7 +54,7 @@ async function run() {
|
||||
}
|
||||
core.endGroup();
|
||||
}
|
||||
setOutput('tags', tags.join(inputs.sepTags));
|
||||
core.setOutput('tags', tags.join(inputs.sepTags));
|
||||
|
||||
// Docker labels
|
||||
const labels: Array<string> = meta.getLabels();
|
||||
@@ -63,21 +63,21 @@ async function run() {
|
||||
core.info(label);
|
||||
}
|
||||
core.endGroup();
|
||||
setOutput('labels', labels.join(inputs.sepLabels));
|
||||
core.setOutput('labels', labels.join(inputs.sepLabels));
|
||||
|
||||
// JSON
|
||||
const jsonOutput = meta.getJSON();
|
||||
core.startGroup(`JSON output`);
|
||||
core.info(JSON.stringify(jsonOutput, null, 2));
|
||||
core.endGroup();
|
||||
setOutput('json', jsonOutput);
|
||||
core.setOutput('json', jsonOutput);
|
||||
|
||||
// Bake definition file
|
||||
// Bake file definition
|
||||
const bakeFile: string = meta.getBakeFile();
|
||||
core.startGroup(`Bake definition file`);
|
||||
core.startGroup(`Bake file definition`);
|
||||
core.info(fs.readFileSync(bakeFile, 'utf8'));
|
||||
core.endGroup();
|
||||
setOutput('bake-file', bakeFile);
|
||||
core.setOutput('bake-file', bakeFile);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
45
src/meta.ts
45
src/meta.ts
@@ -1,7 +1,7 @@
|
||||
import * as handlebars from 'handlebars';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import moment from 'moment';
|
||||
import moment from 'moment-timezone';
|
||||
import * as pep440 from '@renovate/pep440';
|
||||
import * as semver from 'semver';
|
||||
import {Inputs, tmpDir} from './context';
|
||||
@@ -37,6 +37,15 @@ export class Meta {
|
||||
context.ref = `refs/pull/${context.payload.number}/merge`;
|
||||
}
|
||||
|
||||
// DOCKER_METADATA_PR_HEAD_SHA env var can be used to set associated head
|
||||
// SHA instead of commit SHA that triggered the workflow on pull request
|
||||
// event.
|
||||
if (/true/i.test(process.env.DOCKER_METADATA_PR_HEAD_SHA || '')) {
|
||||
if ((/pull_request/.test(context.eventName) || /pull_request_target/.test(context.eventName)) && context.payload?.pull_request?.head?.sha != undefined) {
|
||||
context.sha = context.payload.pull_request.head.sha;
|
||||
}
|
||||
}
|
||||
|
||||
this.inputs = inputs;
|
||||
this.context = context;
|
||||
this.repo = repo;
|
||||
@@ -120,8 +129,19 @@ export class Meta {
|
||||
const currentDate = this.date;
|
||||
const vraw = this.setValue(
|
||||
handlebars.compile(tag.attrs['pattern'])({
|
||||
date: function (format) {
|
||||
return moment(currentDate).utc().format(format);
|
||||
date: function (format, options) {
|
||||
const m = moment(currentDate);
|
||||
let tz = 'UTC';
|
||||
Object.keys(options.hash).forEach(key => {
|
||||
switch (key) {
|
||||
case 'tz':
|
||||
tz = options.hash[key];
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown ${key} attribute`);
|
||||
}
|
||||
});
|
||||
return m.tz(tz).format(format);
|
||||
}
|
||||
}),
|
||||
tag
|
||||
@@ -301,7 +321,7 @@ export class Meta {
|
||||
|
||||
let val = this.context.sha;
|
||||
if (tag.attrs['format'] === tcl.ShaFormat.Short) {
|
||||
val = this.context.sha.substr(0, 7);
|
||||
val = this.context.sha.substring(0, 7);
|
||||
}
|
||||
|
||||
const vraw = this.setValue(val, tag);
|
||||
@@ -367,7 +387,7 @@ export class Meta {
|
||||
return ctx.ref.replace(/^refs\/tags\//g, '');
|
||||
},
|
||||
sha: function () {
|
||||
return ctx.sha.substr(0, 7);
|
||||
return ctx.sha.substring(0, 7);
|
||||
},
|
||||
base_ref: function () {
|
||||
if (/^refs\/tags\//.test(ctx.ref) && ctx.payload?.base_ref != undefined) {
|
||||
@@ -402,8 +422,19 @@ export class Meta {
|
||||
}
|
||||
return 'false';
|
||||
},
|
||||
date: function (format) {
|
||||
return moment(currentDate).utc().format(format);
|
||||
date: function (format, options) {
|
||||
const m = moment(currentDate);
|
||||
let tz = 'UTC';
|
||||
Object.keys(options.hash).forEach(key => {
|
||||
switch (key) {
|
||||
case 'tz':
|
||||
tz = options.hash[key];
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown ${key} attribute`);
|
||||
}
|
||||
});
|
||||
return m.tz(tz).format(format);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -95,7 +95,7 @@ export function Parse(s: string): Tag {
|
||||
for (const field of fields) {
|
||||
const parts = field
|
||||
.toString()
|
||||
.split('=')
|
||||
.split(/(?<=^[^=]+?)=/)
|
||||
.map(item => item.trim());
|
||||
if (parts.length == 1) {
|
||||
tag.attrs['value'] = parts[0];
|
||||
|
@@ -1,3 +1,3 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM alpine
|
||||
|
||||
RUN echo "Hello world!"
|
||||
|
77
yarn.lock
77
yarn.lock
@@ -2,29 +2,30 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@actions/core@^1.6.0":
|
||||
version "1.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.6.0.tgz#0568e47039bfb6a9170393a73f3b7eb3b22462cb"
|
||||
integrity sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==
|
||||
"@actions/core@^1.10.0":
|
||||
version "1.10.0"
|
||||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.0.tgz#44551c3c71163949a2f06e94d9ca2157a0cfac4f"
|
||||
integrity sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==
|
||||
dependencies:
|
||||
"@actions/http-client" "^1.0.11"
|
||||
"@actions/http-client" "^2.0.1"
|
||||
uuid "^8.3.2"
|
||||
|
||||
"@actions/github@^5.0.1":
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@actions/github/-/github-5.0.1.tgz#5fdbe371d9a592038668be95d12421361585fba1"
|
||||
integrity sha512-JZGyPM9ektb8NVTTI/2gfJ9DL7Rk98tQ7OVyTlgTuaQroariRBsOnzjy0I2EarX4xUZpK88YyO503fhmjFdyAg==
|
||||
"@actions/github@^5.1.1":
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@actions/github/-/github-5.1.1.tgz#40b9b9e1323a5efcf4ff7dadd33d8ea51651bbcb"
|
||||
integrity sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g==
|
||||
dependencies:
|
||||
"@actions/http-client" "^1.0.11"
|
||||
"@actions/http-client" "^2.0.1"
|
||||
"@octokit/core" "^3.6.0"
|
||||
"@octokit/plugin-paginate-rest" "^2.17.0"
|
||||
"@octokit/plugin-rest-endpoint-methods" "^5.13.0"
|
||||
|
||||
"@actions/http-client@^1.0.11":
|
||||
version "1.0.11"
|
||||
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.11.tgz#c58b12e9aa8b159ee39e7dd6cbd0e91d905633c0"
|
||||
integrity sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==
|
||||
"@actions/http-client@^2.0.1":
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-2.0.1.tgz#873f4ca98fe32f6839462a6f046332677322f99c"
|
||||
integrity sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==
|
||||
dependencies:
|
||||
tunnel "0.0.6"
|
||||
tunnel "^0.0.6"
|
||||
|
||||
"@ampproject/remapping@^2.1.0":
|
||||
version "2.1.2"
|
||||
@@ -1559,7 +1560,7 @@ combined-stream@^1.0.8:
|
||||
concat-map@0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
|
||||
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
|
||||
|
||||
convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0:
|
||||
version "1.8.0"
|
||||
@@ -1604,10 +1605,10 @@ cssstyle@^2.3.0:
|
||||
dependencies:
|
||||
cssom "~0.3.6"
|
||||
|
||||
csv-parse@*, csv-parse@^5.0.4:
|
||||
version "5.0.4"
|
||||
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-5.0.4.tgz#97e5e654413bcf95f2714ce09bcb2be6de0eb8e3"
|
||||
integrity sha512-5AIdl8l6n3iYQYxan5djB5eKDa+vBnhfWZtRpJTcrETWfVLYN0WSj3L9RwvgYt+psoO77juUr8TG8qpfGZifVQ==
|
||||
csv-parse@*, csv-parse@^5.3.3:
|
||||
version "5.3.3"
|
||||
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-5.3.3.tgz#3b75d2279e2edb550cbc54c65b25cbbf3d0033ad"
|
||||
integrity sha512-kEWkAPleNEdhFNkHQpFHu9RYPogsFj3dx6bCxL847fsiLgidzWg0z/O0B1kVWMJUc5ky64zGp18LX2T3DQrOfw==
|
||||
|
||||
data-urls@^2.0.0:
|
||||
version "2.0.0"
|
||||
@@ -2821,11 +2822,9 @@ json-stable-stringify-without-jsonify@^1.0.1:
|
||||
integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=
|
||||
|
||||
json5@2.x, json5@^2.1.2:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.0.tgz#2dfefe720c6ba525d9ebd909950f0515316c89a3"
|
||||
integrity sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==
|
||||
dependencies:
|
||||
minimist "^1.2.5"
|
||||
version "2.2.3"
|
||||
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
|
||||
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
|
||||
|
||||
kleur@^3.0.3:
|
||||
version "3.0.3"
|
||||
@@ -2942,9 +2941,9 @@ mimic-fn@^2.1.0:
|
||||
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
|
||||
|
||||
minimatch@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
||||
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
|
||||
version "3.1.2"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
|
||||
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
|
||||
dependencies:
|
||||
brace-expansion "^1.1.7"
|
||||
|
||||
@@ -2953,10 +2952,17 @@ minimist@^1.2.5:
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
|
||||
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
|
||||
|
||||
moment@^2.29.3:
|
||||
version "2.29.3"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.3.tgz#edd47411c322413999f7a5940d526de183c031f3"
|
||||
integrity sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw==
|
||||
moment-timezone@^0.5.40:
|
||||
version "0.5.40"
|
||||
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.40.tgz#c148f5149fd91dd3e29bf481abc8830ecba16b89"
|
||||
integrity sha512-tWfmNkRYmBkPJz5mr9GVDn9vRlVZOTe6yqY92rFxiOdWXbjaR0+9LwQnZGGuNR63X456NqmEkbskte8tWL5ePg==
|
||||
dependencies:
|
||||
moment ">= 2.9.0"
|
||||
|
||||
"moment@>= 2.9.0", moment@^2.29.4:
|
||||
version "2.29.4"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
|
||||
integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==
|
||||
|
||||
ms@2.1.2:
|
||||
version "2.1.2"
|
||||
@@ -3553,7 +3559,7 @@ tsutils@^3.21.0:
|
||||
dependencies:
|
||||
tslib "^1.8.1"
|
||||
|
||||
tunnel@0.0.6:
|
||||
tunnel@^0.0.6:
|
||||
version "0.0.6"
|
||||
resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
|
||||
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==
|
||||
@@ -3621,6 +3627,11 @@ uri-js@^4.2.2:
|
||||
dependencies:
|
||||
punycode "^2.1.0"
|
||||
|
||||
uuid@^8.3.2:
|
||||
version "8.3.2"
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
||||
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
|
||||
|
||||
v8-compile-cache-lib@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz#0582bcb1c74f3a2ee46487ceecf372e46bce53e8"
|
||||
|
Reference in New Issue
Block a user