Compare commits
51 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f02d9f4f9b | ||
|
400bd87b5a | ||
|
e4fc7e9e11 | ||
|
9583a0f404 | ||
|
5e6d5157fb | ||
|
e09df4df3c | ||
|
72e5d60481 | ||
|
ae431178c1 | ||
|
34ebfd6e6b | ||
|
94641ff1bb | ||
|
40bfc8b527 | ||
|
2e1a5c7fa4 | ||
|
1a678de43d | ||
|
84b9e75d44 | ||
|
f39f06a624 | ||
|
36ae18e02c | ||
|
e87dd9466c | ||
|
9da1e66de9 | ||
|
521a3c5ada | ||
|
7433b42479 | ||
|
1a8a264b95 | ||
|
e04b4d01a9 | ||
|
ac90ddf06e | ||
|
972129059a | ||
|
b909bd34ef | ||
|
72654174f7 | ||
|
4545671ec8 | ||
|
5c38e5df03 | ||
|
2cbde9dffa | ||
|
2f83320d17 | ||
|
9be43f076d | ||
|
d541d2c17f | ||
|
cffefcd230 | ||
|
00e310993c | ||
|
e696b8439a | ||
|
b334567bf3 | ||
|
7b49f7ed90 | ||
|
e08ef4ca63 | ||
|
5f29dbc7d7 | ||
|
94e634192d | ||
|
cae03854eb | ||
|
0a412843f8 | ||
|
9ae6899cfa | ||
|
db66d4df79 | ||
|
b500d9c7b5 | ||
|
aa3823e012 | ||
|
a4739af83c | ||
|
10e9d5d585 | ||
|
3479bd5aaa | ||
|
c48ac80f46 | ||
|
805449f25e |
@@ -1 +1,2 @@
|
|||||||
node_modules
|
/coverage
|
||||||
|
/node_modules
|
||||||
|
35
.github/CONTRIBUTING.md
vendored
35
.github/CONTRIBUTING.md
vendored
@@ -2,33 +2,20 @@
|
|||||||
|
|
||||||
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
|
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
|
||||||
|
|
||||||
Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE).
|
Contributions to this project are [released](https://docs.github.com/en/github/site-policy/github-terms-of-service#6-contributions-under-repository-license)
|
||||||
|
to the public under the [project's open source license](LICENSE).
|
||||||
|
|
||||||
## Submitting a pull request
|
## Submitting a pull request
|
||||||
|
|
||||||
1. [Fork](https://github.com/crazy-max/ghaction-docker-meta/fork) and clone the repository
|
1. [Fork](https://github.com/crazy-max/ghaction-docker-meta/fork) and clone the repository
|
||||||
2. Configure and install the dependencies: `yarn install`
|
2. Configure and install the dependencies: `yarn install`
|
||||||
3. Make sure the tests pass on your machine: `yarn run test`
|
3. Create a new branch: `git checkout -b my-branch-name`
|
||||||
4. Create a new branch: `git checkout -b my-branch-name`
|
4. Make your changes
|
||||||
5. Make your change, add tests, and make sure the tests still pass
|
5. Make sure the tests pass: `docker buildx bake test`
|
||||||
6. Run pre-checkin: `yarn run pre-checkin`
|
6. Format code and build javascript artifacts: `docker buildx bake pre-checkin`
|
||||||
7. Push to your fork and [submit a pull request](https://github.com/crazy-max/ghaction-docker-meta/compare)
|
7. Validate all code has correctly formatted and built: `docker buildx bake validate`
|
||||||
8. Pat your self on the back and wait for your pull request to be reviewed and merged.
|
8. Push to your fork and [submit a pull request](https://github.com/crazy-max/ghaction-docker-meta/compare)
|
||||||
|
9. Pat your self on the back and wait for your pull request to be reviewed and merged.
|
||||||
## Container based developer flow
|
|
||||||
|
|
||||||
If you don't want to maintain a Node developer environment that fits this project you can use containerized commands instead of invoking yarn directly.
|
|
||||||
|
|
||||||
```
|
|
||||||
# format code and build javascript artifacts
|
|
||||||
docker buildx bake pre-checkin
|
|
||||||
|
|
||||||
# validate all code has correctly formatted and built
|
|
||||||
docker buildx bake validate
|
|
||||||
|
|
||||||
# run tests
|
|
||||||
docker buildx bake test
|
|
||||||
```
|
|
||||||
|
|
||||||
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
|
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
|
||||||
|
|
||||||
@@ -41,5 +28,5 @@ Here are a few things you can do that will increase the likelihood of your pull
|
|||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
||||||
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
|
- [Using Pull Requests](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests)
|
||||||
- [GitHub Help](https://help.github.com)
|
- [GitHub Help](https://docs.github.com/en)
|
||||||
|
3
.github/ISSUE_TEMPLATE/bug_report.md
vendored
3
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -30,4 +30,5 @@ about: Create a report to help us improve
|
|||||||
|
|
||||||
### Logs
|
### Logs
|
||||||
|
|
||||||
> Download the [log file of your build](https://help.github.com/en/actions/configuring-and-managing-workflows/managing-a-workflow-run#downloading-logs) and [attach it](https://help.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue.
|
> Download the [log file of your build](https://docs.github.com/en/actions/managing-workflow-runs/using-workflow-run-logs#downloading-logs)
|
||||||
|
> and [attach it](https://docs.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue.
|
||||||
|
22
.github/labels.yml
vendored
22
.github/labels.yml
vendored
@@ -47,26 +47,34 @@
|
|||||||
name: ":pray: help wanted"
|
name: ":pray: help wanted"
|
||||||
color: "4caf50"
|
color: "4caf50"
|
||||||
description: ""
|
description: ""
|
||||||
- # hold
|
|
||||||
name: ":hand: hold"
|
|
||||||
color: "24292f"
|
|
||||||
description: ""
|
|
||||||
- # invalid
|
- # invalid
|
||||||
name: ":no_entry_sign: invalid"
|
name: ":no_entry_sign: invalid"
|
||||||
color: "e6e6e6"
|
color: "e6e6e6"
|
||||||
description: ""
|
description: ""
|
||||||
- # maybe bug
|
- # investigate
|
||||||
name: ":interrobang: maybe bug"
|
name: ":mag: investigate"
|
||||||
color: "ff5722"
|
color: "e6625b"
|
||||||
description: ""
|
description: ""
|
||||||
- # needs more info
|
- # needs more info
|
||||||
name: ":thinking: needs more info"
|
name: ":thinking: needs more info"
|
||||||
color: "795548"
|
color: "795548"
|
||||||
description: ""
|
description: ""
|
||||||
|
- # pinned
|
||||||
|
name: ":pushpin: pinned"
|
||||||
|
color: "28008e"
|
||||||
|
description: ""
|
||||||
- # question
|
- # question
|
||||||
name: ":question: question"
|
name: ":question: question"
|
||||||
color: "3f51b5"
|
color: "3f51b5"
|
||||||
description: ""
|
description: ""
|
||||||
|
- # sponsor
|
||||||
|
name: ":sparkling_heart: sponsor"
|
||||||
|
color: "fedbf0"
|
||||||
|
description: ""
|
||||||
|
- # stale
|
||||||
|
name: ":skull: stale"
|
||||||
|
color: "237da0"
|
||||||
|
description: ""
|
||||||
- # upstream
|
- # upstream
|
||||||
name: ":eyes: upstream"
|
name: ":eyes: upstream"
|
||||||
color: "fbca04"
|
color: "fbca04"
|
||||||
|
3
.github/stale.yml
vendored
3
.github/stale.yml
vendored
@@ -4,7 +4,8 @@ daysUntilStale: 30
|
|||||||
daysUntilClose: 7
|
daysUntilClose: 7
|
||||||
# Issues with these labels will never be considered stale
|
# Issues with these labels will never be considered stale
|
||||||
exemptLabels:
|
exemptLabels:
|
||||||
- ":hand: hold"
|
- ":pushpin: pinned"
|
||||||
|
- ":game_die: dependencies"
|
||||||
# Set to true to ignore issues in a milestone (defaults to false)
|
# Set to true to ignore issues in a milestone (defaults to false)
|
||||||
exemptMilestones: true
|
exemptMilestones: true
|
||||||
# Label to use when marking an issue as stale
|
# Label to use when marking an issue as stale
|
||||||
|
147
.github/workflows/ci.yml
vendored
147
.github/workflows/ci.yml
vendored
@@ -5,10 +5,14 @@ on:
|
|||||||
- cron: '0 */4 * * *' # every 4 hours
|
- cron: '0 */4 * * *' # every 4 hours
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- 'master'
|
||||||
|
- 'releases/v*'
|
||||||
tags:
|
tags:
|
||||||
- 'v*.*.*'
|
- 'v*.*.*'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
- 'releases/v*'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DOCKER_IMAGE: localhost:5000/name/app
|
DOCKER_IMAGE: localhost:5000/name/app
|
||||||
@@ -27,7 +31,12 @@ jobs:
|
|||||||
images: |
|
images: |
|
||||||
${{ env.DOCKER_IMAGE }}
|
${{ env.DOCKER_IMAGE }}
|
||||||
ghcr.io/name/app
|
ghcr.io/name/app
|
||||||
tag-sha: true
|
tags: |
|
||||||
|
type=schedule
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=tag
|
||||||
|
type=ref,event=pr
|
||||||
|
type=sha
|
||||||
|
|
||||||
tag-schedule:
|
tag-schedule:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -50,8 +59,12 @@ jobs:
|
|||||||
images: |
|
images: |
|
||||||
${{ env.DOCKER_IMAGE }}
|
${{ env.DOCKER_IMAGE }}
|
||||||
ghcr.io/name/app
|
ghcr.io/name/app
|
||||||
tag-sha: true
|
tags: |
|
||||||
tag-schedule: ${{ matrix.tag-schedule }}
|
type=schedule,pattern=${{ matrix.tag-schedule }}
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=tag
|
||||||
|
type=ref,event=pr
|
||||||
|
type=sha
|
||||||
|
|
||||||
tag-match:
|
tag-match:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -59,9 +72,9 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- tag-match: '\d{1,3}.\d{1,3}.\d{1,3}'
|
- tag-match: '\d.\d.\d'
|
||||||
tag-match-group: '0'
|
tag-match-group: '0'
|
||||||
- tag-match: '\d{1,3}.\d{1,3}'
|
- tag-match: '\d.\d'
|
||||||
tag-match-group: '0'
|
tag-match-group: '0'
|
||||||
- tag-match: 'v(.*)'
|
- tag-match: 'v(.*)'
|
||||||
tag-match-group: '1'
|
tag-match-group: '1'
|
||||||
@@ -76,18 +89,23 @@ jobs:
|
|||||||
images: |
|
images: |
|
||||||
${{ env.DOCKER_IMAGE }}
|
${{ env.DOCKER_IMAGE }}
|
||||||
ghcr.io/name/app
|
ghcr.io/name/app
|
||||||
tag-sha: true
|
tags: |
|
||||||
tag-match: ${{ matrix.tag-match }}
|
type=schedule
|
||||||
tag-match-group: ${{ matrix.tag-match-group }}
|
type=ref,event=branch
|
||||||
|
type=ref,event=tag
|
||||||
|
type=ref,event=pr
|
||||||
|
type=match,"pattern=${{ matrix.tag-match }}",group=${{ matrix.tag-match-group }}
|
||||||
|
type=sha
|
||||||
|
|
||||||
tag-semver:
|
tag-semver:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
tag-latest:
|
flavor-latest:
|
||||||
- 'true'
|
- "auto"
|
||||||
- 'false'
|
- "true"
|
||||||
|
- "false"
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
@@ -99,11 +117,53 @@ jobs:
|
|||||||
images: |
|
images: |
|
||||||
${{ env.DOCKER_IMAGE }}
|
${{ env.DOCKER_IMAGE }}
|
||||||
ghcr.io/name/app
|
ghcr.io/name/app
|
||||||
tag-semver: |
|
tags: |
|
||||||
{{raw}}
|
type=schedule
|
||||||
{{version}}
|
type=ref,event=branch
|
||||||
{{major}}.{{minor}}.{{patch}}
|
type=ref,event=tag
|
||||||
tag-latest: ${{ matrix.tag-latest }}
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{raw}}
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}.{{patch}}
|
||||||
|
type=sha
|
||||||
|
flavor: |
|
||||||
|
latest=${{ matrix.flavor-latest }}
|
||||||
|
|
||||||
|
flavor:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
${{ env.DOCKER_IMAGE }}
|
||||||
|
ghcr.io/name/app
|
||||||
|
flavor: |
|
||||||
|
prefix=foo-
|
||||||
|
suffix=-bar
|
||||||
|
|
||||||
|
labels:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
${{ env.DOCKER_IMAGE }}
|
||||||
|
ghcr.io/name/app
|
||||||
|
labels: |
|
||||||
|
maintainer=CrazyMax
|
||||||
|
org.opencontainers.image.title=MyCustomTitle
|
||||||
|
org.opencontainers.image.description=Another description
|
||||||
|
org.opencontainers.image.vendor=MyCompany
|
||||||
|
|
||||||
docker-push:
|
docker-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -122,11 +182,15 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
images: ${{ env.DOCKER_IMAGE }}
|
images: ${{ env.DOCKER_IMAGE }}
|
||||||
tag-sha: true
|
tags: |
|
||||||
tag-semver: |
|
type=schedule
|
||||||
v{{version}}
|
type=ref,event=branch
|
||||||
v{{major}}.{{minor}}
|
type=ref,event=tag
|
||||||
v{{major}}
|
type=ref,event=pr
|
||||||
|
type=semver,pattern=v{{version}}
|
||||||
|
type=semver,pattern=v{{major}}.{{minor}}
|
||||||
|
type=semver,pattern=v{{major}}
|
||||||
|
type=sha
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v1
|
||||||
@@ -158,3 +222,42 @@ jobs:
|
|||||||
name: Dump context
|
name: Dump context
|
||||||
if: always()
|
if: always()
|
||||||
uses: crazy-max/ghaction-dump-context@v1
|
uses: crazy-max/ghaction-dump-context@v1
|
||||||
|
|
||||||
|
bake:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
id: docker_meta
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
${{ env.DOCKER_IMAGE }}
|
||||||
|
ghcr.io/name/app
|
||||||
|
tags: |
|
||||||
|
type=schedule
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=tag
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=sha
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: docker/bake-action@v1
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
./test/docker-bake.hcl
|
||||||
|
${{ steps.docker_meta.outputs.bake-file }}
|
||||||
|
targets: |
|
||||||
|
release
|
||||||
|
18
.github/workflows/label-sponsor.yml
vendored
Normal file
18
.github/workflows/label-sponsor.yml
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
name: label-sponsor
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types:
|
||||||
|
- 'opened'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Set sponsor label
|
||||||
|
uses: JasonEtco/is-sponsor-label-action@024ac24f8b170abce078cad4ee748852369853c8
|
||||||
|
with:
|
||||||
|
label: ":sparkling_heart: sponsor"
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
28
.github/workflows/test.yml
vendored
28
.github/workflows/test.yml
vendored
@@ -8,23 +8,13 @@ on:
|
|||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
- 'releases/v*'
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-containerized:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
|
||||||
name: Validate
|
|
||||||
run: docker buildx bake validate
|
|
||||||
-
|
|
||||||
name: Test
|
|
||||||
run: docker buildx bake test
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -32,15 +22,17 @@ jobs:
|
|||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
-
|
-
|
||||||
name: Install
|
name: Validate
|
||||||
run: yarn install
|
uses: docker/bake-action@v1
|
||||||
|
with:
|
||||||
|
targets: validate
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
run: yarn run test
|
uses: docker/bake-action@v1
|
||||||
|
with:
|
||||||
|
targets: test
|
||||||
-
|
-
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
uses: codecov/codecov-action@v1
|
uses: codecov/codecov-action@v1
|
||||||
if: success()
|
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
|
||||||
file: ./coverage/clover.xml
|
file: ./coverage/clover.xml
|
||||||
|
74
CHANGELOG.md
74
CHANGELOG.md
@@ -1,5 +1,79 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2.5.0 (2021/05/08)
|
||||||
|
|
||||||
|
* Major version zero doc (#74)
|
||||||
|
* Bump hosted-git-info from 2.8.8 to 2.8.9 (#73)
|
||||||
|
* Bump lodash from 4.17.20 to 4.17.21 (#72)
|
||||||
|
* Handle global expressions (#71)
|
||||||
|
|
||||||
|
## 2.4.0 (2021/04/30)
|
||||||
|
|
||||||
|
* Add `bake-target` input (#69)
|
||||||
|
* Fix setOutput (#67)
|
||||||
|
* Bump csv-parse from 4.15.3 to 4.15.4 (#65)
|
||||||
|
* Bump @actions/core from 1.2.6 to 1.2.7 (#64)
|
||||||
|
|
||||||
|
## 2.3.0 (2021/04/07)
|
||||||
|
|
||||||
|
* Allow overriding flavor (#63)
|
||||||
|
* Prefix/suffix not taken into account for `match`, `semver` and `schedule` types (#62)
|
||||||
|
|
||||||
|
## 2.2.1 (2021/04/05)
|
||||||
|
|
||||||
|
* Skip and display warning if tag does not match (#59)
|
||||||
|
|
||||||
|
## 2.2.0 (2021/04/03)
|
||||||
|
|
||||||
|
* Improve logging (#58)
|
||||||
|
* Fix README (#56)
|
||||||
|
|
||||||
|
## 2.1.1 (2021/03/30)
|
||||||
|
|
||||||
|
* Fix `enable` tag attribute (#53)
|
||||||
|
* Bump y18n from 4.0.0 to 4.0.1 (#54)
|
||||||
|
|
||||||
|
## 2.1.0 (2021/03/29)
|
||||||
|
|
||||||
|
* Bump semver from 7.3.4 to 7.3.5 (#49)
|
||||||
|
* Enhance workflow (#51)
|
||||||
|
|
||||||
|
## 2.0.0 (2021/03/29)
|
||||||
|
|
||||||
|
This release includes significant changes (#50). Please read the [upgrade notes](UPGRADE.md) for a smooth migration.
|
||||||
|
`v1` is still available through [`releases/v1` branch](https://github.com/crazy-max/ghaction-docker-meta/tree/releases/v1).
|
||||||
|
|
||||||
|
* Add `tags` input
|
||||||
|
* Inputs `tag-sha`, `tag-edge`, `tag-edge-branch`, `tag-semver`, `tag-match`, `tag-match-group`, `tag-schedule`, `tag-custom`, `tag-custom-only` have been removed and are now handled through the new `tags` input
|
||||||
|
* Input `label-custom` renamed `labels`
|
||||||
|
* Add `flavor` input to handle a global prefix, suffix and latest tag behavior (#13 #15 #41)
|
||||||
|
* Input `tag-latest` removed (use `flavor` input instead)
|
||||||
|
* Manage tag sorting through `priority` attribute in `tags` input (#27)
|
||||||
|
* Explicit control over the conditions of each tag through `enable` attribute in `tags` input (#30)
|
||||||
|
* Allow `semver` and `match` parsing for custom values (#25 #30)
|
||||||
|
* Display warning message if not tag generated
|
||||||
|
|
||||||
|
## 1.12.0 (2021/03/19)
|
||||||
|
|
||||||
|
* Ignore commas for `label-custom` input (#48)
|
||||||
|
* Bump handlebars from 4.7.6 to 4.7.7 (#44)
|
||||||
|
* Bump csv-parse from 4.14.2 to 4.15.3 (#42 #45)
|
||||||
|
|
||||||
|
## 1.11.0 (2020/12/24)
|
||||||
|
|
||||||
|
* Inject `DOCKER_META_IMAGES` and `DOCKER_META_VERSION` args in bake definition (#37)
|
||||||
|
|
||||||
|
## 1.10.1 (2020/12/24)
|
||||||
|
|
||||||
|
* Missing entry in `action.yml`
|
||||||
|
|
||||||
|
## 1.10.0 (2020/12/24)
|
||||||
|
|
||||||
|
* Add `bake-file` output (#36)
|
||||||
|
* Add `label-custom` input (#35)
|
||||||
|
* Bump node-notifier from 8.0.0 to 8.0.1 (#33)
|
||||||
|
* Update dev workflow (#32)
|
||||||
|
|
||||||
## 1.9.1 (2020/12/07)
|
## 1.9.1 (2020/12/07)
|
||||||
|
|
||||||
* Replace forbidden chars derived from branch name (#31)
|
* Replace forbidden chars derived from branch name (#31)
|
||||||
|
42
Dockerfile
42
Dockerfile
@@ -1,42 +0,0 @@
|
|||||||
#syntax=docker/dockerfile:1.1-experimental
|
|
||||||
|
|
||||||
FROM node:12 AS deps
|
|
||||||
WORKDIR /src
|
|
||||||
COPY package.json yarn.lock ./
|
|
||||||
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn \
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
FROM scratch AS update-yarn
|
|
||||||
COPY --from=deps /src/yarn.lock /
|
|
||||||
|
|
||||||
FROM deps AS validate-yarn
|
|
||||||
COPY .git .git
|
|
||||||
RUN status=$(git status --porcelain -- yarn.lock); if [ -n "$status" ]; then echo $status; exit 1; fi
|
|
||||||
|
|
||||||
FROM deps AS base
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
FROM base AS build
|
|
||||||
RUN yarn build
|
|
||||||
|
|
||||||
FROM deps AS test
|
|
||||||
COPY . .
|
|
||||||
RUN yarn run test
|
|
||||||
|
|
||||||
FROM base AS run-format
|
|
||||||
RUN yarn run format
|
|
||||||
|
|
||||||
FROM scratch AS format
|
|
||||||
COPY --from=run-format /src/src/*.ts /src/
|
|
||||||
|
|
||||||
FROM base AS validate-format
|
|
||||||
RUN yarn run format-check
|
|
||||||
|
|
||||||
FROM scratch AS dist
|
|
||||||
COPY --from=build /src/dist/ /dist/
|
|
||||||
|
|
||||||
FROM build AS validate-build
|
|
||||||
RUN status=$(git status --porcelain -- dist); if [ -n "$status" ]; then echo $status; exit 1; fi
|
|
||||||
|
|
||||||
FROM base AS dev
|
|
||||||
ENTRYPOINT ["bash"]
|
|
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2020 CrazyMax
|
Copyright (c) 2020-2021 CrazyMax
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
610
README.md
610
README.md
@@ -5,6 +5,10 @@
|
|||||||
[](https://github.com/sponsors/crazy-max)
|
[](https://github.com/sponsors/crazy-max)
|
||||||
[](https://www.paypal.me/crazyws)
|
[](https://www.paypal.me/crazyws)
|
||||||
|
|
||||||
|
## Upgrade from v1
|
||||||
|
|
||||||
|
`v2` of this action includes significant changes. Please read the [upgrade notes](UPGRADE.md) for a smooth migration.
|
||||||
|
|
||||||
## About
|
## About
|
||||||
|
|
||||||
GitHub Action to extract metadata (tags, labels) for Docker. This action is particularly useful if used with
|
GitHub Action to extract metadata (tags, labels) for Docker. This action is particularly useful if used with
|
||||||
@@ -16,52 +20,47 @@ If you are interested, [check out](https://git.io/Je09Y) my other :octocat: GitH
|
|||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
* [Features](#features)
|
|
||||||
* [Usage](#usage)
|
* [Usage](#usage)
|
||||||
* [Basic](#basic)
|
* [Basic](#basic)
|
||||||
* [Semver](#semver)
|
* [Semver](#semver)
|
||||||
* [Complete](#complete)
|
* [Bake definition](#bake-definition)
|
||||||
* [Customizing](#customizing)
|
* [Customizing](#customizing)
|
||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
* [outputs](#outputs)
|
* [outputs](#outputs)
|
||||||
|
* [`flavor` input](#flavor-input)
|
||||||
|
* [`tags` input](#tags-input)
|
||||||
|
* [`type=schedule`](#typeschedule)
|
||||||
|
* [`type=semver`](#typesemver)
|
||||||
|
* [`type=match`](#typematch)
|
||||||
|
* [`type=edge`](#typeedge)
|
||||||
|
* [`type=ref`](#typeref)
|
||||||
|
* [`type=raw`](#typeraw)
|
||||||
|
* [`type=sha`](#typesha)
|
||||||
* [Notes](#notes)
|
* [Notes](#notes)
|
||||||
* [Latest tag](#latest-tag)
|
* [Latest tag](#latest-tag)
|
||||||
* [Handle semver tag](#handle-semver-tag)
|
* [Global expressions](#global-expressions)
|
||||||
* [`tag-match` examples](#tag-match-examples)
|
* [Major version zero](#major-version-zero)
|
||||||
* [Schedule tag](#schedule-tag)
|
|
||||||
* [Overwrite labels](#overwrite-labels)
|
* [Overwrite labels](#overwrite-labels)
|
||||||
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
|
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
|
||||||
* [How can I help?](#how-can-i-help)
|
* [Contributing](#contributing)
|
||||||
* [License](#license)
|
* [License](#license)
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
* Docker tags generated from GitHub action event and Git metadata
|
|
||||||
* [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
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Basic
|
### Basic
|
||||||
|
|
||||||
| 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` | `v1.2.3`, `latest` |
|
|
||||||
| `push tag` | `refs/tags/v2.0.8-beta.67` | `fc89efd` | `v2.0.8-beta.67`, `latest` |
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: ci
|
name: ci
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- 'master'
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
@@ -72,16 +71,10 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
id: docker_meta
|
id: meta
|
||||||
uses: crazy-max/ghaction-docker-meta@v1
|
uses: crazy-max/ghaction-docker-meta@v2
|
||||||
with:
|
with:
|
||||||
images: name/app
|
images: name/app
|
||||||
-
|
|
||||||
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
|
name: Login to DockerHub
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
@@ -94,33 +87,33 @@ jobs:
|
|||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
|
||||||
platforms: linux/amd64,linux/arm64,linux/386
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
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` |
|
||||||
|
|
||||||
### Semver
|
### 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
|
```yaml
|
||||||
name: ci
|
name: ci
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- 'master'
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
@@ -131,19 +124,15 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
id: docker_meta
|
id: meta
|
||||||
uses: crazy-max/ghaction-docker-meta@v1
|
uses: crazy-max/ghaction-docker-meta@v2
|
||||||
with:
|
with:
|
||||||
images: name/app
|
images: name/app
|
||||||
tag-semver: |
|
tags: |
|
||||||
{{version}}
|
type=ref,event=branch
|
||||||
{{major}}.{{minor}}
|
type=ref,event=pr
|
||||||
-
|
type=semver,pattern={{version}}
|
||||||
name: Set up QEMU
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
-
|
-
|
||||||
name: Login to DockerHub
|
name: Login to DockerHub
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
@@ -156,36 +145,46 @@ jobs:
|
|||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
|
||||||
platforms: linux/amd64,linux/arm64,linux/386
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Complete
|
| 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` | `1.2.3`, `1.2`, `latest` |
|
||||||
|
| `push tag` | `refs/tags/v2.0.8-beta.67` | `2.0.8-beta.67` |
|
||||||
|
|
||||||
| Event | Ref | Commit SHA | Docker Tags |
|
### Bake definition
|
||||||
|-----------------|-------------------------------|------------|-----------------------------------------|
|
|
||||||
| `schedule` | `refs/heads/master` | `45f132a` | `sha-45f132a`, `nightly` |
|
This action also handles a bake definition file that can be used with the
|
||||||
| `pull_request` | `refs/pull/2/merge` | `a123b57` | `sha-a123b57`, `pr-2` |
|
[Docker Bake action](https://github.com/docker/bake-action). You just have to declare an empty target named
|
||||||
| `push` | `refs/heads/master` | `cf20257` | `sha-cf20257`, `master` |
|
`ghaction-docker-meta` and inherit from it.
|
||||||
| `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` |
|
```hcl
|
||||||
| `push tag` | `refs/tags/v2.0.8-beta.67` | `fc89efd` | `sha-fc89efd`, `2.0.8-beta.67` |
|
// docker-bake.hcl
|
||||||
|
target "ghaction-docker-meta" {}
|
||||||
|
|
||||||
|
target "build" {
|
||||||
|
inherits = ["ghaction-docker-meta"]
|
||||||
|
context = "./"
|
||||||
|
dockerfile = "Dockerfile"
|
||||||
|
platforms = ["linux/amd64", "linux/arm/v6", "linux/arm/v7", "linux/arm64", "linux/386", "linux/ppc64le"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: ci
|
name: ci
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
|
||||||
- cron: '0 10 * * *' # everyday at 10am
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- 'master'
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
@@ -196,37 +195,55 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
id: docker_meta
|
id: meta
|
||||||
uses: crazy-max/ghaction-docker-meta@v1
|
uses: crazy-max/ghaction-docker-meta@v2
|
||||||
with:
|
with:
|
||||||
images: name/app
|
images: name/app
|
||||||
tag-sha: true
|
tags: |
|
||||||
tag-semver: |
|
type=ref,event=branch
|
||||||
{{version}}
|
type=ref,event=pr
|
||||||
{{major}}.{{minor}}
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=sha
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Build
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/bake-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:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
files: |
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
./docker-bake.hcl
|
||||||
-
|
${{ steps.meta.outputs.bake-file }}
|
||||||
name: Build and push
|
targets: build
|
||||||
uses: docker/build-push-action@v2
|
```
|
||||||
with:
|
|
||||||
context: .
|
Content of `${{ steps.meta.outputs.bake-file }}` file will look like this with `refs/tags/v1.2.3` ref:
|
||||||
file: ./Dockerfile
|
|
||||||
platforms: linux/amd64,linux/arm64,linux/386
|
```json
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
{
|
||||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
"target": {
|
||||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
"ghaction-docker-meta": {
|
||||||
|
"tags": [
|
||||||
|
"name/app:1.2.3",
|
||||||
|
"name/app:1.2",
|
||||||
|
"name/app:sha-90dd603",
|
||||||
|
"name/app:latest"
|
||||||
|
],
|
||||||
|
"labels": {
|
||||||
|
"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.2.3",
|
||||||
|
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||||
|
"org.opencontainers.image.licenses": "MIT"
|
||||||
|
},
|
||||||
|
"args": {
|
||||||
|
"DOCKER_META_IMAGES": "name/app",
|
||||||
|
"DOCKER_META_VERSION": "1.2.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Customizing
|
## Customizing
|
||||||
@@ -235,25 +252,28 @@ jobs:
|
|||||||
|
|
||||||
Following inputs can be used as `step.with` keys
|
Following inputs can be used as `step.with` keys
|
||||||
|
|
||||||
|
> `List` type is a newline-delimited string
|
||||||
|
> ```yaml
|
||||||
|
> labels: |
|
||||||
|
> org.opencontainers.image.title=MyCustomTitle
|
||||||
|
> org.opencontainers.image.description=Another description
|
||||||
|
> org.opencontainers.image.vendor=MyCompany
|
||||||
|
> ```
|
||||||
|
|
||||||
|
> `CSV` type is a comma-delimited string
|
||||||
|
> ```yaml
|
||||||
|
> images: name/app,ghcr.io/name/app
|
||||||
|
> ```
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
|---------------------|----------|------------------------------------|
|
|---------------------|----------|------------------------------------|
|
||||||
| `images` | List/CSV | List of Docker images to use as base name for tags |
|
| `images` | List/CSV | List of Docker images to use as base name for tags |
|
||||||
| `tag-sha` | Bool | Add git short SHA as Docker tag (default `false`) |
|
| `tags` | List | List of [tags](#tags-input) as key-value pair attributes |
|
||||||
| `tag-edge` | Bool | Enable edge branch tagging (default `false`) |
|
| `flavor` | List | [Flavor](#flavor-input) to apply |
|
||||||
| `tag-edge-branch` | String | Branch that will be tagged as edge (default `repo.default_branch`) |
|
| `labels` | List | List of custom labels |
|
||||||
| `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-group` | Number | Group to get if `tag-match` matches (default `0`) |
|
|
||||||
| `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-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`) |
|
||||||
|
| `bake-target` | String | Bake target name (default `ghaction-docker-meta`) |
|
||||||
> List/CSV type can be a newline or comma delimited string
|
|
||||||
|
|
||||||
> `tag-semver` and `tag-match` are mutually exclusive
|
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|
||||||
@@ -261,63 +281,318 @@ Following outputs are available
|
|||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
|---------------|---------|---------------------------------------|
|
|---------------|---------|---------------------------------------|
|
||||||
| `version` | String | Generated Docker image version |
|
| `version` | String | Docker image version |
|
||||||
| `tags` | String | Generated Docker tags |
|
| `tags` | String | Docker tags |
|
||||||
| `labels` | String | Generated Docker labels |
|
| `labels` | String | Docker labels |
|
||||||
|
| `bake-file` | File | [Bake definition file](https://github.com/docker/buildx#file-definition) path |
|
||||||
|
|
||||||
|
## `flavor` input
|
||||||
|
|
||||||
|
`flavor` defines a global behavior for [`tags`](#tags-input):
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
flavor: |
|
||||||
|
latest=auto
|
||||||
|
prefix=
|
||||||
|
suffix=
|
||||||
|
```
|
||||||
|
|
||||||
|
* `latest=<auto|true|false>`: Handle [latest tag](#latest-tag) (default `auto`)
|
||||||
|
* `prefix=<string>`: A global prefix for each generated tag
|
||||||
|
* `suffix=<string>`: A global suffix for each generated tag
|
||||||
|
|
||||||
|
## `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
|
||||||
|
(only string format is handled in the input fields). Here is an example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
type=schedule
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=sha
|
||||||
|
```
|
||||||
|
|
||||||
|
Each entry is defined by a `type`, which are:
|
||||||
|
|
||||||
|
* [`type=schedule`](#typeschedule)
|
||||||
|
* [`type=semver`](#typesemver)
|
||||||
|
* [`type=match`](#typematch)
|
||||||
|
* [`type=edge`](#typeedge)
|
||||||
|
* [`type=ref`](#typeref)
|
||||||
|
* [`type=raw`](#typeraw)
|
||||||
|
* [`type=sha`](#typesha)
|
||||||
|
|
||||||
|
And global attributes:
|
||||||
|
|
||||||
|
* `enable=<true|false>` enable this entry (default `true`)
|
||||||
|
* `priority=<number>` priority to manage the order of tags
|
||||||
|
* `prefix=<string>` add prefix
|
||||||
|
* `suffix=<string>` add suffix
|
||||||
|
|
||||||
|
Default entries if `tags` input is empty:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
type=schedule
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=tag
|
||||||
|
type=ref,event=pr
|
||||||
|
```
|
||||||
|
|
||||||
|
### `type=schedule`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
# minimal
|
||||||
|
type=schedule
|
||||||
|
# default
|
||||||
|
type=schedule,pattern=nightly
|
||||||
|
# handlebars
|
||||||
|
type=schedule,pattern={{date 'YYYYMMDD'}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Will be used on [schedule event](https://docs.github.com/en/actions/reference/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 | Output |
|
||||||
|
|--------------------------|----------------------|
|
||||||
|
| `nightly` | `nightly` |
|
||||||
|
| `{{date 'YYYYMMDD'}}` | `20210326` |
|
||||||
|
|
||||||
|
Extended attributes and default values:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
type=schedule,enable=true,priority=1000,prefix=,suffix=,pattern=nightly
|
||||||
|
```
|
||||||
|
|
||||||
|
### `type=semver`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
# minimal
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
# use custom value instead of git tag
|
||||||
|
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 Git tag [semver](https://semver.org/) but you can also use a custom value through `value`
|
||||||
|
attribute.
|
||||||
|
|
||||||
|
`pattern` attribute supports [Handlebars template](https://handlebarsjs.com/guide/) with the following expressions:
|
||||||
|
* `raw` ; the actual semver
|
||||||
|
* `version` ; shorthand for `{{major}}.{{minor}}.{{patch}}` (can include pre-release)
|
||||||
|
* `major` ; major version identifier
|
||||||
|
* `minor` ; minor version identifier
|
||||||
|
* `patch` ; patch version identifier
|
||||||
|
|
||||||
|
| Git tag | Pattern | Output |
|
||||||
|
|--------------------|----------------------------------------------------------|----------------------|
|
||||||
|
| `v1.2.3` | `{{raw}}` | `v1.2.3` |
|
||||||
|
| `v1.2.3` | `{{version}}` | `1.2.3` |
|
||||||
|
| `v1.2.3` | `{{major}}.{{minor}}` | `1.2` |
|
||||||
|
| `v1.2.3` | `v{{major}}` | `v1` |
|
||||||
|
| `v1.2.3` | `{{minor}}` | `2` |
|
||||||
|
| `v1.2.3` | `{{patch}}` | `3` |
|
||||||
|
| `v2.0.8-beta.67` | `{{raw}}` | `2.0.8-beta.67`* |
|
||||||
|
| `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}}` 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:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
type=semver,enable=true,priority=900,prefix=,suffix=,pattern=,value=
|
||||||
|
```
|
||||||
|
|
||||||
|
### `type=match`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
# minimal
|
||||||
|
type=match,pattern=\d.\d.\d
|
||||||
|
# define match group
|
||||||
|
type=match,pattern=v(.*),group=1
|
||||||
|
# use custom value instead of git tag
|
||||||
|
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.
|
||||||
|
|
||||||
|
| Git tag | Pattern | Group | Output |
|
||||||
|
|-------------------------|-------------------------------|---------|------------------------|
|
||||||
|
| `v1.2.3` | `\d.\d.\d` | `0` | `1.2.3` |
|
||||||
|
| `v2.0.8-beta.67` | `v(.*)` | `1` | `2.0.8-beta.67` |
|
||||||
|
| `v2.0.8-beta.67` | `v(\d.\d)` | `1` | `2.0` |
|
||||||
|
| `20200110-RC2` | `\d+` | `0` | `20200110` |
|
||||||
|
| `p1/v1.2.3` | `p1-v(\d.\d.\d)` | `1` | `1.2.3` |
|
||||||
|
|
||||||
|
Extended attributes and default values:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
type=match,enable=true,priority=800,prefix=,suffix=,pattern=,group=0,value=
|
||||||
|
```
|
||||||
|
|
||||||
|
### `type=edge`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
# minimal
|
||||||
|
type=edge
|
||||||
|
# define default branch
|
||||||
|
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).
|
||||||
|
|
||||||
|
Extended attributes and default values:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
type=edge,enable=true,priority=700,prefix=,suffix=,branch=$repo.default_branch
|
||||||
|
```
|
||||||
|
|
||||||
|
### `type=ref`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
# branch event
|
||||||
|
type=ref,event=branch
|
||||||
|
# tag event
|
||||||
|
type=ref,event=tag
|
||||||
|
# pull request event
|
||||||
|
type=ref,event=pr
|
||||||
|
```
|
||||||
|
|
||||||
|
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` |
|
||||||
|
|
||||||
|
Extended attributes and default values:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
# branch event
|
||||||
|
type=ref,enable=true,priority=600,prefix=,suffix=,event=
|
||||||
|
# tag event
|
||||||
|
type=ref,enable=true,priority=600,prefix=,suffix=,event=
|
||||||
|
# pull request event
|
||||||
|
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=
|
||||||
|
```
|
||||||
|
|
||||||
|
### `type=raw`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
type=raw,value=foo
|
||||||
|
type=raw,value=bar
|
||||||
|
# or
|
||||||
|
type=raw,foo
|
||||||
|
type=raw,bar
|
||||||
|
# or
|
||||||
|
foo
|
||||||
|
bar
|
||||||
|
```
|
||||||
|
|
||||||
|
Output custom tags according to your needs.
|
||||||
|
|
||||||
|
Extended attributes and default values:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
type=raw,enable=true,priority=200,prefix=,suffix=,value=
|
||||||
|
```
|
||||||
|
|
||||||
|
### `type=sha`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
# minimal
|
||||||
|
type=sha
|
||||||
|
```
|
||||||
|
|
||||||
|
Output Git short commit as Docker tag like `sha-ad132f5`.
|
||||||
|
|
||||||
|
Extended attributes and default values:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
type=sha,enable=true,priority=100,prefix=sha-,suffix=
|
||||||
|
```
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
### Latest tag
|
### Latest tag
|
||||||
|
|
||||||
Latest Docker tag will be generated by default on `push tag` event. If for example you push the `v1.2.3` Git tag,
|
`latest` tag is handled through the [`flavor` input](#flavor-input). It will be generated by default (`auto` mode) for:
|
||||||
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
|
* [`type=ref,event=tag`](#typeref)
|
||||||
generated only if `tag-semver` is a valid [semver](https://semver.org/) or if Git tag matches a regular expression
|
* [`type=semver,pattern=...`](#typesemver)
|
||||||
with the [`tag-match` input](#tag-match-examples). Can be disabled if `tag-latest` is `false`.
|
* [`type=match,pattern=...`](#typematch)
|
||||||
|
|
||||||
### Handle semver tag
|
### Global expressions
|
||||||
|
|
||||||
If Git tag is a valid [semver](https://semver.org/) you can handle it to output multi Docker tags at once.
|
The following [Handlebars template](https://handlebarsjs.com/guide/) expressions for `prefix`, `suffix` and `value`
|
||||||
`tag-semver` supports multi-line [Handlebars template](https://handlebarsjs.com/guide/) with the following inputs:
|
attributes are available:
|
||||||
|
|
||||||
| Git tag | `tag-semver` | Valid | Output tags | Output version |
|
| Expression | Output |
|
||||||
|--------------------|----------------------------------------------------------|--------------------|----------------------------|------------------------------|
|
|--------------------------|----------------------|
|
||||||
| `v1.2.3` | `{{raw}}` | :white_check_mark: | `v1.2.3`, `latest` | `v1.2.3` |
|
| `{{branch}}` | `master` |
|
||||||
| `v1.2.3` | `{{version}}` | :white_check_mark: | `1.2.3`, `latest` | `1.2.3` |
|
| `{{tag}}` | `v1.2.3` |
|
||||||
| `v1.2.3` | `{{major}}.{{minor}}` | :white_check_mark: | `1.2`, `latest` | `1.2` |
|
| `{{sha}}` | `90dd603` |
|
||||||
| `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`
|
```yaml
|
||||||
|
tags: |
|
||||||
|
# dynamically set the branch name as a prefix
|
||||||
|
type=sha,prefix={{branch}}-
|
||||||
|
# dynamically set the branch name and sha as a custom tag
|
||||||
|
type=raw,value=mytag-{{branch}}-{{sha}}
|
||||||
|
```
|
||||||
|
|
||||||
> **Pre-release (rc, beta, alpha) will only extend `{{version}}` as tag because they are updated frequently,
|
### Major version zero
|
||||||
> and contain many breaking changes that are (by the author's design) not yet fit for public consumption.
|
|
||||||
|
|
||||||
### `tag-match` examples
|
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).
|
||||||
|
|
||||||
| Git tag | `tag-match` | `tag-match-group` | Match | Output tags | Output version |
|
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:
|
||||||
| `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` | `2.0.8-beta.67` |
|
|
||||||
| `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` |
|
|
||||||
| `20200110-RC2` | `\d+` | `0` | :white_check_mark: | `20200110`, `latest` | `20200110` |
|
|
||||||
|
|
||||||
### Schedule tag
|
```yaml
|
||||||
|
# refs/tags/v0.1.2
|
||||||
`tag-schedule` is specially crafted input to support [Handlebars template](https://handlebarsjs.com/guide/) with
|
tags: |
|
||||||
the following expressions:
|
# output 0.1.2
|
||||||
|
type=semver,pattern={{version}}
|
||||||
| Expression | Example | Description |
|
# output 0.1
|
||||||
|-------------------------|-------------------------------------------|------------------------------------------|
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
| `{{date 'format'}}` | `{{date 'YYYYMMDD'}}` > `20200110` | Render date by its [moment format](https://momentjs.com/docs/#/displaying/format/)
|
# disabled if major zero
|
||||||
|
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
|
||||||
You can find more examples in the [CI workflow](.github/workflows/ci.yml).
|
```
|
||||||
|
|
||||||
### Overwrite labels
|
### Overwrite labels
|
||||||
|
|
||||||
@@ -326,16 +601,13 @@ labels generated are not suitable, you can overwrite them like this:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Docker meta
|
||||||
uses: docker/build-push-action@v2
|
id: docker_meta
|
||||||
|
uses: crazy-max/ghaction-docker-meta@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
images: name/app
|
||||||
file: ./Dockerfile
|
|
||||||
platforms: linux/amd64,linux/arm64,linux/386
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
||||||
labels: |
|
labels: |
|
||||||
${{ steps.docker_meta.outputs.labels }}
|
maintainer=CrazyMax
|
||||||
org.opencontainers.image.title=MyCustomTitle
|
org.opencontainers.image.title=MyCustomTitle
|
||||||
org.opencontainers.image.description=Another description
|
org.opencontainers.image.description=Another description
|
||||||
org.opencontainers.image.vendor=MyCompany
|
org.opencontainers.image.vendor=MyCompany
|
||||||
@@ -357,12 +629,14 @@ updates:
|
|||||||
interval: "daily"
|
interval: "daily"
|
||||||
```
|
```
|
||||||
|
|
||||||
## How can I help?
|
## Contributing
|
||||||
|
|
||||||
All kinds of contributions are welcome :raised_hands:! The most basic way to show your support is to star :star2:
|
Want to contribute? Awesome! The most basic way to show your support is to star :star2: the project,
|
||||||
the project, or to raise issues :speech_balloon: You can also support this project by
|
or to raise issues :speech_balloon:. If you want to open a pull request, please read the
|
||||||
[**becoming a sponsor on GitHub**](https://github.com/sponsors/crazy-max) :clap: or by making a
|
[contributing guidelines](.github/CONTRIBUTING.md).
|
||||||
[Paypal donation](https://www.paypal.me/crazyws) to ensure this journey continues indefinitely! :rocket:
|
|
||||||
|
You can also support this project by [**becoming a sponsor on GitHub**](https://github.com/sponsors/crazy-max) or by
|
||||||
|
making a [Paypal donation](https://www.paypal.me/crazyws) to ensure this journey continues indefinitely!
|
||||||
|
|
||||||
Thanks again for your support, it is much appreciated! :pray:
|
Thanks again for your support, it is much appreciated! :pray:
|
||||||
|
|
||||||
|
294
UPGRADE.md
Normal file
294
UPGRADE.md
Normal file
@@ -0,0 +1,294 @@
|
|||||||
|
# Upgrade notes
|
||||||
|
|
||||||
|
## v1 to v2
|
||||||
|
|
||||||
|
* [inputs](#inputs)
|
||||||
|
* [`tag-sha`](#tag-sha)
|
||||||
|
* [`tag-edge` / `tag-edge-branch`](#tag-edge--tag-edge-branch)
|
||||||
|
* [`tag-semver`](#tag-semver)
|
||||||
|
* [`tag-match` / `tag-match-group`](#tag-match--tag-match-group)
|
||||||
|
* [`tag-latest`](#tag-latest)
|
||||||
|
* [`tag-schedule`](#tag-schedule)
|
||||||
|
* [`tag-custom` / `tag-custom-only`](#tag-custom--tag-custom-only)
|
||||||
|
* [`label-custom`](#label-custom)
|
||||||
|
* [Basic workflow](#basic-workflow)
|
||||||
|
* [Semver workflow](#semver-workflow)
|
||||||
|
|
||||||
|
### inputs
|
||||||
|
|
||||||
|
| New | Unchanged | Removed |
|
||||||
|
|------------|-----------------|--------------------|
|
||||||
|
| `tags` | `images` | `tag-sha` |
|
||||||
|
| `flavor` | `sep-tags` | `tag-edge` |
|
||||||
|
| `labels` | `sep-labels` | `tag-edge-branch` |
|
||||||
|
| | | `tag-semver` |
|
||||||
|
| | | `tag-match` |
|
||||||
|
| | | `tag-match-group` |
|
||||||
|
| | | `tag-latest` |
|
||||||
|
| | | `tag-schedule` |
|
||||||
|
| | | `tag-custom` |
|
||||||
|
| | | `tag-custom-only` |
|
||||||
|
| | | `label-custom` |
|
||||||
|
|
||||||
|
#### `tag-sha`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
type=sha
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `tag-edge` / `tag-edge-branch`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
# default branch
|
||||||
|
type=edge
|
||||||
|
# specify branch
|
||||||
|
type=edge,branch=main
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `tag-semver`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `tag-match` / `tag-match-group`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
type=match,pattern=v(.*),group=1
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `tag-latest`
|
||||||
|
|
||||||
|
`tag-latest` is now handled through the [`flavor` input](README.md#flavor-input):
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
flavor: |
|
||||||
|
latest=auto
|
||||||
|
```
|
||||||
|
|
||||||
|
See also the notes about ["latest tag" behavior](README.md#latest-tag)
|
||||||
|
|
||||||
|
#### `tag-schedule`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
# default tag (nightly)
|
||||||
|
type=schedule
|
||||||
|
# specific pattern
|
||||||
|
type=schedule,pattern={{date 'YYYYMMDD'}}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `tag-custom` / `tag-custom-only`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
tags: |
|
||||||
|
type=raw,value=foo
|
||||||
|
type=raw,value=bar
|
||||||
|
# or
|
||||||
|
type=raw,foo
|
||||||
|
type=raw,bar
|
||||||
|
# or
|
||||||
|
foo
|
||||||
|
bar
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `label-custom`
|
||||||
|
|
||||||
|
Same behavior for `labels`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
labels: |
|
||||||
|
maintainer=CrazyMax
|
||||||
|
```
|
||||||
|
|
||||||
|
### Basic workflow
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# v1
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: crazy-max/ghaction-docker-meta@v1
|
||||||
|
with:
|
||||||
|
images: name/app
|
||||||
|
-
|
||||||
|
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: .
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# v2
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: crazy-max/ghaction-docker-meta@v2
|
||||||
|
with:
|
||||||
|
images: name/app
|
||||||
|
-
|
||||||
|
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: .
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Semver workflow
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# v1
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: crazy-max/ghaction-docker-meta@v1
|
||||||
|
with:
|
||||||
|
images: name/app
|
||||||
|
tag-semver: |
|
||||||
|
{{version}}
|
||||||
|
{{major}}.{{minor}}
|
||||||
|
-
|
||||||
|
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: .
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# v2
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: crazy-max/ghaction-docker-meta@v2
|
||||||
|
with:
|
||||||
|
images: name/app
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
-
|
||||||
|
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: .
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
```
|
@@ -1,54 +1,162 @@
|
|||||||
|
import * as fs from 'fs';
|
||||||
|
import * as os from 'os';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
import * as context from '../src/context';
|
import * as context from '../src/context';
|
||||||
|
|
||||||
|
jest.spyOn(context, 'tmpDir').mockImplementation((): string => {
|
||||||
|
const tmpDir = path.join('/tmp/.ghaction-docker-meta-jest').split(path.sep).join(path.posix.sep);
|
||||||
|
if (!fs.existsSync(tmpDir)) {
|
||||||
|
fs.mkdirSync(tmpDir, {recursive: true});
|
||||||
|
}
|
||||||
|
return tmpDir;
|
||||||
|
});
|
||||||
|
|
||||||
describe('getInputList', () => {
|
describe('getInputList', () => {
|
||||||
it('handles single line correctly', async () => {
|
it('single line correctly', async () => {
|
||||||
await setInput('foo', 'bar');
|
await setInput('foo', 'bar');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
console.log(res);
|
||||||
expect(res).toEqual(['bar']);
|
expect(res).toEqual(['bar']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles multiple lines correctly', async () => {
|
it('multiline correctly', async () => {
|
||||||
setInput('foo', 'bar\nbaz');
|
setInput('foo', 'bar\nbaz');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
console.log(res);
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
expect(res).toEqual(['bar', 'baz']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('remove empty lines correctly', async () => {
|
it('empty lines correctly', async () => {
|
||||||
setInput('foo', 'bar\n\nbaz');
|
setInput('foo', 'bar\n\nbaz');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
console.log(res);
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
expect(res).toEqual(['bar', 'baz']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles comma correctly', async () => {
|
it('comma correctly', async () => {
|
||||||
setInput('foo', 'bar,baz');
|
setInput('foo', 'bar,baz');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
console.log(res);
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
expect(res).toEqual(['bar', 'baz']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('remove empty result correctly', async () => {
|
it('empty result correctly', async () => {
|
||||||
setInput('foo', 'bar,baz,');
|
setInput('foo', 'bar,baz,');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
console.log(res);
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
expect(res).toEqual(['bar', 'baz']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles different new lines correctly', async () => {
|
it('different new lines correctly', async () => {
|
||||||
setInput('foo', 'bar\r\nbaz');
|
setInput('foo', 'bar\r\nbaz');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
console.log(res);
|
||||||
expect(res).toEqual(['bar', 'baz']);
|
expect(res).toEqual(['bar', 'baz']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles different new lines and comma correctly', async () => {
|
it('different new lines and comma correctly', async () => {
|
||||||
setInput('foo', 'bar\r\nbaz,bat');
|
setInput('foo', 'bar\r\nbaz,bat');
|
||||||
const res = await context.getInputList('foo');
|
const res = await context.getInputList('foo');
|
||||||
console.log(res);
|
console.log(res);
|
||||||
expect(res).toEqual(['bar', 'baz', 'bat']);
|
expect(res).toEqual(['bar', 'baz', 'bat']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('multiline and ignoring comma correctly', async () => {
|
||||||
|
setInput('cache-from', 'user/app:cache\ntype=local,src=path/to/dir');
|
||||||
|
const res = await context.getInputList('cache-from', true);
|
||||||
|
console.log(res);
|
||||||
|
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('different new lines and ignoring comma correctly', async () => {
|
||||||
|
setInput('cache-from', 'user/app:cache\r\ntype=local,src=path/to/dir');
|
||||||
|
const res = await context.getInputList('cache-from', true);
|
||||||
|
console.log(res);
|
||||||
|
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('multiline values', async () => {
|
||||||
|
setInput(
|
||||||
|
'secrets',
|
||||||
|
`GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789
|
||||||
|
"MYSECRET=aaaaaaaa
|
||||||
|
bbbbbbb
|
||||||
|
ccccccccc"
|
||||||
|
FOO=bar`
|
||||||
|
);
|
||||||
|
const res = await context.getInputList('secrets', true);
|
||||||
|
console.log(res);
|
||||||
|
expect(res).toEqual([
|
||||||
|
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
||||||
|
`MYSECRET=aaaaaaaa
|
||||||
|
bbbbbbb
|
||||||
|
ccccccccc`,
|
||||||
|
'FOO=bar'
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('multiline values with empty lines', async () => {
|
||||||
|
setInput(
|
||||||
|
'secrets',
|
||||||
|
`GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789
|
||||||
|
"MYSECRET=aaaaaaaa
|
||||||
|
bbbbbbb
|
||||||
|
ccccccccc"
|
||||||
|
FOO=bar
|
||||||
|
"EMPTYLINE=aaaa
|
||||||
|
|
||||||
|
bbbb
|
||||||
|
ccc"`
|
||||||
|
);
|
||||||
|
const res = await context.getInputList('secrets', true);
|
||||||
|
console.log(res);
|
||||||
|
expect(res).toEqual([
|
||||||
|
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
||||||
|
`MYSECRET=aaaaaaaa
|
||||||
|
bbbbbbb
|
||||||
|
ccccccccc`,
|
||||||
|
'FOO=bar',
|
||||||
|
`EMPTYLINE=aaaa
|
||||||
|
|
||||||
|
bbbb
|
||||||
|
ccc`
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('multiline values without quotes', async () => {
|
||||||
|
setInput(
|
||||||
|
'secrets',
|
||||||
|
`GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789
|
||||||
|
MYSECRET=aaaaaaaa
|
||||||
|
bbbbbbb
|
||||||
|
ccccccccc
|
||||||
|
FOO=bar`
|
||||||
|
);
|
||||||
|
const res = await context.getInputList('secrets', true);
|
||||||
|
console.log(res);
|
||||||
|
expect(res).toEqual(['GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789', 'MYSECRET=aaaaaaaa', 'bbbbbbb', 'ccccccccc', 'FOO=bar']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('multiline values escape quotes', async () => {
|
||||||
|
setInput(
|
||||||
|
'secrets',
|
||||||
|
`GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789
|
||||||
|
"MYSECRET=aaaaaaaa
|
||||||
|
bbbb""bbb
|
||||||
|
ccccccccc"
|
||||||
|
FOO=bar`
|
||||||
|
);
|
||||||
|
const res = await context.getInputList('secrets', true);
|
||||||
|
console.log(res);
|
||||||
|
expect(res).toEqual([
|
||||||
|
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
||||||
|
`MYSECRET=aaaaaaaa
|
||||||
|
bbbb\"bbb
|
||||||
|
ccccccccc`,
|
||||||
|
'FOO=bar'
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('asyncForEach', () => {
|
describe('asyncForEach', () => {
|
||||||
@@ -64,6 +172,27 @@ describe('asyncForEach', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('setOutput', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
process.stdout.write = jest.fn();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('setOutput produces the correct command', () => {
|
||||||
|
context.setOutput('some output', 'some value');
|
||||||
|
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('setOutput handles bools', () => {
|
||||||
|
context.setOutput('some output', false);
|
||||||
|
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
|
||||||
|
});
|
||||||
|
|
||||||
|
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
|
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
||||||
function getInputName(name: string): string {
|
function getInputName(name: string): string {
|
||||||
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||||
@@ -72,3 +201,11 @@ function getInputName(name: string): string {
|
|||||||
function setInput(name: string, value: string): void {
|
function setInput(name: string, value: string): void {
|
||||||
process.env[getInputName(name)] = value;
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
23
__tests__/fixtures/event_tag_p1-v1.0.0.env
Normal file
23
__tests__/fixtures/event_tag_p1-v1.0.0.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_6ee180c2-b331-434a-a867-89534cbefd83
|
||||||
|
GITHUB_EVENT_NAME=push
|
||||||
|
#GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
|
||||||
|
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
|
||||||
|
GITHUB_HEAD_REF=
|
||||||
|
GITHUB_JOB=event
|
||||||
|
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_6ee180c2-b331-434a-a867-89534cbefd83
|
||||||
|
GITHUB_REF=refs/tags/p1/v1.0.0
|
||||||
|
GITHUB_REPOSITORY=crazy-max/test-docker-action
|
||||||
|
GITHUB_REPOSITORY_OWNER=crazy-max
|
||||||
|
GITHUB_RETENTION_DAYS=90
|
||||||
|
GITHUB_RUN_ID=325968230
|
||||||
|
GITHUB_RUN_NUMBER=4
|
||||||
|
GITHUB_SERVER_URL=https://github.com
|
||||||
|
GITHUB_SHA=90dd6032fac8bda1b6c4436a2e65de27961ed071
|
||||||
|
GITHUB_WORKFLOW=event
|
||||||
|
GITHUB_WORKSPACE=/home/runner/work/test-docker-action/test-docker-action
|
115
__tests__/flavor.test.ts
Normal file
115
__tests__/flavor.test.ts
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
import {Flavor, Transform} from '../src/flavor';
|
||||||
|
|
||||||
|
describe('transform', () => {
|
||||||
|
// prettier-ignore
|
||||||
|
test.each([
|
||||||
|
[
|
||||||
|
[
|
||||||
|
`randomstr`,
|
||||||
|
`latest=auto`
|
||||||
|
],
|
||||||
|
{} as Flavor,
|
||||||
|
true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
`unknwown=foo`
|
||||||
|
],
|
||||||
|
{} as Flavor,
|
||||||
|
true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
`latest`,
|
||||||
|
],
|
||||||
|
{} as Flavor,
|
||||||
|
true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
`latest=true`
|
||||||
|
],
|
||||||
|
{
|
||||||
|
latest: "true",
|
||||||
|
prefix: "",
|
||||||
|
suffix: ""
|
||||||
|
} as Flavor,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
`latest=false`
|
||||||
|
],
|
||||||
|
{
|
||||||
|
latest: "false",
|
||||||
|
prefix: "",
|
||||||
|
suffix: ""
|
||||||
|
} as Flavor,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
`latest=auto`
|
||||||
|
],
|
||||||
|
{
|
||||||
|
latest: "auto",
|
||||||
|
prefix: "",
|
||||||
|
suffix: ""
|
||||||
|
} as Flavor,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
`latest=foo`
|
||||||
|
],
|
||||||
|
{} as Flavor,
|
||||||
|
true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
`prefix=sha-`
|
||||||
|
],
|
||||||
|
{
|
||||||
|
latest: "auto",
|
||||||
|
prefix: "sha-",
|
||||||
|
suffix: ""
|
||||||
|
} as Flavor,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
`suffix=-alpine`
|
||||||
|
],
|
||||||
|
{
|
||||||
|
latest: "auto",
|
||||||
|
prefix: "",
|
||||||
|
suffix: "-alpine"
|
||||||
|
} as Flavor,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
`latest=false`,
|
||||||
|
`prefix=dev-`,
|
||||||
|
`suffix=-alpine`
|
||||||
|
],
|
||||||
|
{
|
||||||
|
latest: "false",
|
||||||
|
prefix: "dev-",
|
||||||
|
suffix: "-alpine"
|
||||||
|
} as Flavor,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
])('given %p attributes ', async (inputs: string[], expected: Flavor, invalid: boolean) => {
|
||||||
|
try {
|
||||||
|
const flavor = Transform(inputs);
|
||||||
|
console.log(flavor);
|
||||||
|
expect(flavor).toEqual(expected);
|
||||||
|
} catch (err) {
|
||||||
|
if (!invalid) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
expect(true).toBe(invalid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
File diff suppressed because it is too large
Load Diff
419
__tests__/tag.test.ts
Normal file
419
__tests__/tag.test.ts
Normal file
@@ -0,0 +1,419 @@
|
|||||||
|
import {Transform, Parse, Tag, Type, RefEvent, DefaultPriorities} from '../src/tag';
|
||||||
|
|
||||||
|
describe('transform', () => {
|
||||||
|
// prettier-ignore
|
||||||
|
test.each([
|
||||||
|
[
|
||||||
|
[
|
||||||
|
`type=ref,event=branch`,
|
||||||
|
`type=ref,event=tag`,
|
||||||
|
`type=ref,event=pr`,
|
||||||
|
`type=schedule`,
|
||||||
|
`type=sha`,
|
||||||
|
`type=raw,foo`,
|
||||||
|
`type=edge`,
|
||||||
|
`type=semver,pattern={{version}}`,
|
||||||
|
`type=match,"pattern=\\d.\\d.\\d",group=0`
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
type: Type.Schedule,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Schedule],
|
||||||
|
"enable": "true",
|
||||||
|
"pattern": "nightly"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: Type.Semver,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Semver],
|
||||||
|
"enable": "true",
|
||||||
|
"pattern": "{{version}}",
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: Type.Match,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Match],
|
||||||
|
"enable": "true",
|
||||||
|
"pattern": "\\d.\\d.\\d",
|
||||||
|
"group": "0",
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: Type.Edge,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Edge],
|
||||||
|
"enable": "true",
|
||||||
|
"branch": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: Type.Ref,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Ref],
|
||||||
|
"enable": "true",
|
||||||
|
"event": RefEvent.Branch
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: Type.Ref,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Ref],
|
||||||
|
"enable": "true",
|
||||||
|
"event": RefEvent.Tag
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: Type.Ref,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Ref],
|
||||||
|
"enable": "true",
|
||||||
|
"prefix": "pr-",
|
||||||
|
"event": RefEvent.PR
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: Type.Raw,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Raw],
|
||||||
|
"enable": "true",
|
||||||
|
"value": "foo"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: Type.Sha,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Sha],
|
||||||
|
"enable": "true",
|
||||||
|
"prefix": "sha-"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
] as Tag[],
|
||||||
|
false
|
||||||
|
]
|
||||||
|
])('given %p', async (l: string[], expected: Tag[], invalid: boolean) => {
|
||||||
|
try {
|
||||||
|
const tags = Transform(l);
|
||||||
|
console.log(tags);
|
||||||
|
expect(tags).toEqual(expected);
|
||||||
|
} catch (err) {
|
||||||
|
if (!invalid) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
expect(true).toBe(invalid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('parse', () => {
|
||||||
|
// prettier-ignore
|
||||||
|
test.each([
|
||||||
|
[
|
||||||
|
`type=schedule,enable=true,pattern={{date 'YYYYMMDD'}}`,
|
||||||
|
{
|
||||||
|
type: Type.Schedule,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Schedule],
|
||||||
|
"enable": "true",
|
||||||
|
"pattern": "{{date 'YYYYMMDD'}}"
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=semver,enable=true,pattern={{version}}`,
|
||||||
|
{
|
||||||
|
type: Type.Semver,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Semver],
|
||||||
|
"enable": "true",
|
||||||
|
"pattern": "{{version}}",
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=semver,priority=1,enable=true,pattern={{version}}`,
|
||||||
|
{
|
||||||
|
type: Type.Semver,
|
||||||
|
attrs: {
|
||||||
|
"priority": "1",
|
||||||
|
"enable": "true",
|
||||||
|
"pattern": "{{version}}",
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=semver,priority=1,enable=true,pattern={{version}},value=v1.0.0`,
|
||||||
|
{
|
||||||
|
type: Type.Semver,
|
||||||
|
attrs: {
|
||||||
|
"priority": "1",
|
||||||
|
"enable": "true",
|
||||||
|
"pattern": "{{version}}",
|
||||||
|
"value": "v1.0.0"
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=match,enable=true,pattern=v(.*),group=1`,
|
||||||
|
{
|
||||||
|
type: Type.Match,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Match],
|
||||||
|
"enable": "true",
|
||||||
|
"pattern": "v(.*)",
|
||||||
|
"group": "1",
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=match,enable=true,"pattern=^v(\\d.\\d.\\d)$",group=1`,
|
||||||
|
{
|
||||||
|
type: Type.Match,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Match],
|
||||||
|
"enable": "true",
|
||||||
|
"pattern": "^v(\\d.\\d.\\d)$",
|
||||||
|
"group": "1",
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=match,priority=700,enable=true,pattern=v(.*),group=1`,
|
||||||
|
{
|
||||||
|
type: Type.Match,
|
||||||
|
attrs: {
|
||||||
|
"priority": "700",
|
||||||
|
"enable": "true",
|
||||||
|
"pattern": "v(.*)",
|
||||||
|
"group": "1",
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=match,enable=true,pattern=v(.*),group=1,value=v1.2.3`,
|
||||||
|
{
|
||||||
|
type: Type.Match,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Match],
|
||||||
|
"enable": "true",
|
||||||
|
"pattern": "v(.*)",
|
||||||
|
"group": "1",
|
||||||
|
"value": "v1.2.3"
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=match,enable=true,pattern=v(.*),group=foo`,
|
||||||
|
{} as Tag,
|
||||||
|
true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=edge`,
|
||||||
|
{
|
||||||
|
type: Type.Edge,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Edge],
|
||||||
|
"enable": "true",
|
||||||
|
"branch": ""
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=edge,enable=true,branch=master`,
|
||||||
|
{
|
||||||
|
type: Type.Edge,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Edge],
|
||||||
|
"enable": "true",
|
||||||
|
"branch": "master"
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=ref,event=tag`,
|
||||||
|
{
|
||||||
|
type: Type.Ref,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Ref],
|
||||||
|
"enable": "true",
|
||||||
|
"event": RefEvent.Tag
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=ref,event=branch`,
|
||||||
|
{
|
||||||
|
type: Type.Ref,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Ref],
|
||||||
|
"enable": "true",
|
||||||
|
"event": RefEvent.Branch
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=ref,event=pr`,
|
||||||
|
{
|
||||||
|
type: Type.Ref,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Ref],
|
||||||
|
"enable": "true",
|
||||||
|
"prefix": "pr-",
|
||||||
|
"event": RefEvent.PR
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=ref,event=foo`,
|
||||||
|
{} as Tag,
|
||||||
|
true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=ref`,
|
||||||
|
{} as Tag,
|
||||||
|
true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`acustomtag`,
|
||||||
|
{
|
||||||
|
type: Type.Raw,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Raw],
|
||||||
|
"enable": "true",
|
||||||
|
"value": "acustomtag"
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=raw`,
|
||||||
|
{} as Tag,
|
||||||
|
true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=raw,value=acustomtag2`,
|
||||||
|
{
|
||||||
|
type: Type.Raw,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Raw],
|
||||||
|
"enable": "true",
|
||||||
|
"value": "acustomtag2"
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=raw,enable=true,value=acustomtag4`,
|
||||||
|
{
|
||||||
|
type: Type.Raw,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Raw],
|
||||||
|
"enable": "true",
|
||||||
|
"value": "acustomtag4"
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=raw,enable=false,value=acustomtag5`,
|
||||||
|
{
|
||||||
|
type: Type.Raw,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Raw],
|
||||||
|
"enable": "false",
|
||||||
|
"value": "acustomtag5"
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=sha`,
|
||||||
|
{
|
||||||
|
type: Type.Sha,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Sha],
|
||||||
|
"enable": "true",
|
||||||
|
"prefix": "sha-"
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=sha,prefix=`,
|
||||||
|
{
|
||||||
|
type: Type.Sha,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Sha],
|
||||||
|
"enable": "true",
|
||||||
|
"prefix": ""
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=sha,enable=false`,
|
||||||
|
{
|
||||||
|
type: Type.Sha,
|
||||||
|
attrs: {
|
||||||
|
"priority": DefaultPriorities[Type.Sha],
|
||||||
|
"enable": "false",
|
||||||
|
"prefix": "sha-"
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=semver`,
|
||||||
|
{} as Tag,
|
||||||
|
true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=match`,
|
||||||
|
{} as Tag,
|
||||||
|
true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=foo`,
|
||||||
|
{} as Tag,
|
||||||
|
true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=sha,enable=foo`,
|
||||||
|
{} as Tag,
|
||||||
|
true
|
||||||
|
]
|
||||||
|
])('given %p event ', async (s: string, expected: Tag, invalid: boolean) => {
|
||||||
|
try {
|
||||||
|
const tag = Parse(s);
|
||||||
|
console.log(tag);
|
||||||
|
expect(tag).toEqual(expected);
|
||||||
|
} catch (err) {
|
||||||
|
if (!invalid) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
expect(true).toBe(invalid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
48
action.yml
48
action.yml
@@ -10,45 +10,14 @@ inputs:
|
|||||||
images:
|
images:
|
||||||
description: 'List of Docker images to use as base name for tags'
|
description: 'List of Docker images to use as base name for tags'
|
||||||
required: true
|
required: true
|
||||||
tag-sha:
|
tags:
|
||||||
description: 'Add git short SHA as Docker tag'
|
description: 'List of tags as key-value pair attributes'
|
||||||
default: 'false'
|
|
||||||
required: false
|
required: false
|
||||||
tag-edge:
|
flavor:
|
||||||
description: 'Enable edge branch tagging'
|
description: 'Flavors to apply'
|
||||||
default: 'false'
|
|
||||||
required: false
|
required: false
|
||||||
tag-edge-branch:
|
labels:
|
||||||
description: 'Branch that will be tagged as edge (default repo.default_branch)'
|
description: 'List of custom labels'
|
||||||
required: false
|
|
||||||
tag-semver:
|
|
||||||
description: 'Handle Git tag as semver template if possible'
|
|
||||||
required: false
|
|
||||||
tag-match:
|
|
||||||
description: 'RegExp to match against a Git tag and use match group as Docker tag'
|
|
||||||
required: false
|
|
||||||
tag-match-group:
|
|
||||||
description: 'Group to get if tag-match matches (default 0)'
|
|
||||||
default: '0'
|
|
||||||
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:
|
|
||||||
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'
|
|
||||||
required: false
|
|
||||||
tag-schedule:
|
|
||||||
description: 'Template to apply to schedule tag'
|
|
||||||
default: 'nightly'
|
|
||||||
required: false
|
|
||||||
tag-custom:
|
|
||||||
description: 'List of custom tags'
|
|
||||||
required: false
|
|
||||||
tag-custom-only:
|
|
||||||
description: 'Only use tag-custom as Docker tags'
|
|
||||||
required: false
|
required: false
|
||||||
sep-tags:
|
sep-tags:
|
||||||
description: 'Separator to use for tags output (default \n)'
|
description: 'Separator to use for tags output (default \n)'
|
||||||
@@ -56,6 +25,9 @@ inputs:
|
|||||||
sep-labels:
|
sep-labels:
|
||||||
description: 'Separator to use for labels output (default \n)'
|
description: 'Separator to use for labels output (default \n)'
|
||||||
required: false
|
required: false
|
||||||
|
bake-target:
|
||||||
|
description: 'Bake target name (default ghaction-docker-meta)'
|
||||||
|
required: false
|
||||||
github-token:
|
github-token:
|
||||||
description: 'GitHub Token as provided by secrets'
|
description: 'GitHub Token as provided by secrets'
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
@@ -68,6 +40,8 @@ outputs:
|
|||||||
description: 'Generated Docker tags'
|
description: 'Generated Docker tags'
|
||||||
labels:
|
labels:
|
||||||
description: 'Generated Docker labels'
|
description: 'Generated Docker labels'
|
||||||
|
bake-file:
|
||||||
|
description: 'Bake definiton file'
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
|
2218
dist/index.js
generated
vendored
2218
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
@@ -1,42 +1,67 @@
|
|||||||
|
variable "NODE_VERSION" {
|
||||||
|
default = "12"
|
||||||
|
}
|
||||||
|
|
||||||
|
target "node-version" {
|
||||||
|
args = {
|
||||||
|
NODE_VERSION = NODE_VERSION
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
group "default" {
|
group "default" {
|
||||||
targets = ["build"]
|
targets = ["build"]
|
||||||
}
|
}
|
||||||
|
|
||||||
group "pre-checkin" {
|
group "pre-checkin" {
|
||||||
targets = ["update-yarn", "format", "build"]
|
targets = ["vendor-update", "format", "build"]
|
||||||
}
|
}
|
||||||
|
|
||||||
group "validate" {
|
group "validate" {
|
||||||
targets = ["validate-format", "validate-build", "validate-yarn"]
|
targets = ["format-validate", "build-validate", "vendor-validate"]
|
||||||
}
|
|
||||||
|
|
||||||
target "update-yarn" {
|
|
||||||
target = "update-yarn"
|
|
||||||
output = ["."]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
target "build" {
|
target "build" {
|
||||||
target = "dist"
|
inherits = ["node-version"]
|
||||||
|
dockerfile = "./hack/build.Dockerfile"
|
||||||
|
target = "build-update"
|
||||||
output = ["."]
|
output = ["."]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "test" {
|
target "build-validate" {
|
||||||
target = "test"
|
inherits = ["node-version"]
|
||||||
|
dockerfile = "./hack/build.Dockerfile"
|
||||||
|
target = "build-validate"
|
||||||
}
|
}
|
||||||
|
|
||||||
target "format" {
|
target "format" {
|
||||||
target = "format"
|
inherits = ["node-version"]
|
||||||
|
dockerfile = "./hack/build.Dockerfile"
|
||||||
|
target = "format-update"
|
||||||
output = ["."]
|
output = ["."]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "validate-format" {
|
target "format-validate" {
|
||||||
target = "validate-format"
|
inherits = ["node-version"]
|
||||||
|
dockerfile = "./hack/build.Dockerfile"
|
||||||
|
target = "format-validate"
|
||||||
}
|
}
|
||||||
|
|
||||||
target "validate-build" {
|
target "vendor-update" {
|
||||||
target = "validate-build"
|
inherits = ["node-version"]
|
||||||
|
dockerfile = "./hack/vendor.Dockerfile"
|
||||||
|
target = "update"
|
||||||
|
output = ["."]
|
||||||
}
|
}
|
||||||
|
|
||||||
target "validate-yarn" {
|
target "vendor-validate" {
|
||||||
target = "validate-yarn"
|
inherits = ["node-version"]
|
||||||
|
dockerfile = "./hack/vendor.Dockerfile"
|
||||||
|
target = "validate"
|
||||||
|
}
|
||||||
|
|
||||||
|
target "test" {
|
||||||
|
inherits = ["node-version"]
|
||||||
|
dockerfile = "./hack/test.Dockerfile"
|
||||||
|
target = "test-coverage"
|
||||||
|
output = ["./coverage"]
|
||||||
}
|
}
|
||||||
|
42
hack/build.Dockerfile
Normal file
42
hack/build.Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# syntax=docker/dockerfile:1.2
|
||||||
|
ARG NODE_VERSION
|
||||||
|
|
||||||
|
FROM node:${NODE_VERSION}-alpine AS base
|
||||||
|
RUN apk add --no-cache cpio findutils git
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
FROM base AS deps
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
FROM deps AS build
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn run build && mkdir /out && cp -Rf dist /out/
|
||||||
|
|
||||||
|
FROM scratch AS build-update
|
||||||
|
COPY --from=build /out /
|
||||||
|
|
||||||
|
FROM build AS build-validate
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
git add -A && cp -rf /out/* .; \
|
||||||
|
if [ -n "$(git status --porcelain -- dist)" ]; then \
|
||||||
|
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'; \
|
||||||
|
git status --porcelain -- dist; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
FROM deps AS format
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn run format \
|
||||||
|
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out
|
||||||
|
|
||||||
|
FROM scratch AS format-update
|
||||||
|
COPY --from=format /out /
|
||||||
|
|
||||||
|
FROM deps AS format-validate
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn run format-check \
|
21
hack/test.Dockerfile
Normal file
21
hack/test.Dockerfile
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# syntax=docker/dockerfile:1.2
|
||||||
|
ARG NODE_VERSION
|
||||||
|
|
||||||
|
FROM node:${NODE_VERSION}-alpine AS base
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
FROM base AS deps
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
FROM deps AS test
|
||||||
|
ENV RUNNER_TEMP=/tmp/github_runner
|
||||||
|
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn run test --coverageDirectory=/tmp/coverage
|
||||||
|
|
||||||
|
FROM scratch AS test-coverage
|
||||||
|
COPY --from=test /tmp/coverage /
|
23
hack/vendor.Dockerfile
Normal file
23
hack/vendor.Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# syntax=docker/dockerfile:1.2
|
||||||
|
ARG NODE_VERSION
|
||||||
|
|
||||||
|
FROM node:${NODE_VERSION}-alpine AS base
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
FROM base AS vendored
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
--mount=type=cache,target=/src/node_modules \
|
||||||
|
yarn install && mkdir /out && cp yarn.lock /out
|
||||||
|
|
||||||
|
FROM scratch AS update
|
||||||
|
COPY --from=vendored /out /
|
||||||
|
|
||||||
|
FROM vendored AS validate
|
||||||
|
RUN --mount=type=bind,target=.,rw \
|
||||||
|
git add -A && cp -rf /out/* .; \
|
||||||
|
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then \
|
||||||
|
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \
|
||||||
|
git status --porcelain -- yarn.lock; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
@@ -23,11 +23,12 @@
|
|||||||
"author": "CrazyMax",
|
"author": "CrazyMax",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.7",
|
||||||
"@actions/github": "^4.0.0",
|
"@actions/github": "^4.0.0",
|
||||||
"handlebars": "^4.7.6",
|
"csv-parse": "^4.15.4",
|
||||||
|
"handlebars": "^4.7.7",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"semver": "^7.3.4"
|
"semver": "^7.3.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.0",
|
"@types/jest": "^26.0.0",
|
||||||
|
@@ -1,50 +1,67 @@
|
|||||||
|
import csvparse from 'csv-parse/lib/sync';
|
||||||
import * as core from '@actions/core';
|
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';
|
||||||
|
|
||||||
|
let _tmpDir: string;
|
||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
images: string[];
|
images: string[];
|
||||||
tagSha: boolean;
|
tags: string[];
|
||||||
tagEdge: boolean;
|
flavor: string[];
|
||||||
tagEdgeBranch: string;
|
labels: string[];
|
||||||
tagSemver: string[];
|
|
||||||
tagMatch: string;
|
|
||||||
tagMatchGroup: number;
|
|
||||||
tagLatest: boolean;
|
|
||||||
tagSchedule: string;
|
|
||||||
tagCustom: string[];
|
|
||||||
tagCustomOnly: boolean;
|
|
||||||
sepTags: string;
|
sepTags: string;
|
||||||
sepLabels: string;
|
sepLabels: string;
|
||||||
|
bakeTarget: string;
|
||||||
githubToken: string;
|
githubToken: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function tmpDir(): string {
|
||||||
|
if (!_tmpDir) {
|
||||||
|
_tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ghaction-docker-meta-')).split(path.sep).join(path.posix.sep);
|
||||||
|
}
|
||||||
|
return _tmpDir;
|
||||||
|
}
|
||||||
|
|
||||||
export function getInputs(): Inputs {
|
export function getInputs(): Inputs {
|
||||||
return {
|
return {
|
||||||
images: getInputList('images'),
|
images: getInputList('images'),
|
||||||
tagSha: /true/i.test(core.getInput('tag-sha') || 'false'),
|
tags: getInputList('tags', true),
|
||||||
tagEdge: /true/i.test(core.getInput('tag-edge') || 'false'),
|
flavor: getInputList('flavor', true),
|
||||||
tagEdgeBranch: core.getInput('tag-edge-branch'),
|
labels: getInputList('labels', true),
|
||||||
tagSemver: getInputList('tag-semver'),
|
|
||||||
tagMatch: core.getInput('tag-match'),
|
|
||||||
tagMatchGroup: Number(core.getInput('tag-match-group')) || 0,
|
|
||||||
tagLatest: /true/i.test(core.getInput('tag-latest') || core.getInput('tag-match-latest') || 'true'),
|
|
||||||
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`,
|
||||||
|
bakeTarget: core.getInput('bake-target') || `ghaction-docker-meta`,
|
||||||
githubToken: core.getInput('github-token')
|
githubToken: core.getInput('github-token')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getInputList(name: string): string[] {
|
export function getInputList(name: string, ignoreComma?: boolean): string[] {
|
||||||
|
let res: Array<string> = [];
|
||||||
|
|
||||||
const items = core.getInput(name);
|
const items = core.getInput(name);
|
||||||
if (items == '') {
|
if (items == '') {
|
||||||
return [];
|
return res;
|
||||||
}
|
}
|
||||||
return items
|
|
||||||
.split(/\r?\n/)
|
for (let output of csvparse(items, {
|
||||||
.filter(x => x)
|
columns: false,
|
||||||
.reduce<string[]>((acc, line) => acc.concat(line.split(',').filter(x => x)).map(pat => pat.trim()), []);
|
relaxColumnCount: true,
|
||||||
|
skipLinesWithEmptyValues: true
|
||||||
|
}) as Array<string[]>) {
|
||||||
|
if (output.length == 1) {
|
||||||
|
res.push(output[0]);
|
||||||
|
continue;
|
||||||
|
} else if (!ignoreComma) {
|
||||||
|
res.push(...output);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
res.push(output.join(','));
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.filter(item => item).map(pat => pat.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
export const asyncForEach = async (array, callback) => {
|
export const asyncForEach = async (array, callback) => {
|
||||||
@@ -52,3 +69,8 @@ export const asyncForEach = async (array, callback) => {
|
|||||||
await callback(array[index], index, array);
|
await callback(array[index], index, array);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
||||||
|
export function setOutput(name: string, value: any): void {
|
||||||
|
issueCommand('set-output', {name}, value);
|
||||||
|
}
|
||||||
|
50
src/flavor.ts
Normal file
50
src/flavor.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
|
export interface Flavor {
|
||||||
|
latest: string;
|
||||||
|
prefix: string;
|
||||||
|
suffix: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Transform(inputs: string[]): Flavor {
|
||||||
|
const flavor: Flavor = {
|
||||||
|
latest: 'auto',
|
||||||
|
prefix: '',
|
||||||
|
suffix: ''
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const input of inputs) {
|
||||||
|
const parts = input.split('=', 2);
|
||||||
|
if (parts.length == 1) {
|
||||||
|
throw new Error(`Invalid entry: ${input}`);
|
||||||
|
}
|
||||||
|
switch (parts[0]) {
|
||||||
|
case 'latest': {
|
||||||
|
flavor.latest = parts[1];
|
||||||
|
if (!['auto', 'true', 'false'].includes(flavor.latest)) {
|
||||||
|
throw new Error(`Invalid latest flavor entry: ${input}`);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'prefix': {
|
||||||
|
flavor.prefix = parts[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'suffix': {
|
||||||
|
flavor.suffix = parts[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
throw new Error(`Unknown entry: ${input}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
core.startGroup(`Processing flavor input`);
|
||||||
|
core.info(`latest=${flavor.latest}`);
|
||||||
|
core.info(`prefix=${flavor.prefix}`);
|
||||||
|
core.info(`suffix=${flavor.suffix}`);
|
||||||
|
core.endGroup();
|
||||||
|
|
||||||
|
return flavor;
|
||||||
|
}
|
30
src/main.ts
30
src/main.ts
@@ -1,4 +1,5 @@
|
|||||||
import {getInputs, Inputs} from './context';
|
import * as fs from 'fs';
|
||||||
|
import {getInputs, Inputs, setOutput} from './context';
|
||||||
import * as github from './github';
|
import * as github from './github';
|
||||||
import {Meta, Version} from './meta';
|
import {Meta, Version} from './meta';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
@@ -28,26 +29,43 @@ 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;
|
||||||
|
if (meta.version.main == undefined || meta.version.main.length == 0) {
|
||||||
|
core.warning(`No Docker image version has been generated. Check tags input.`);
|
||||||
|
} else {
|
||||||
core.startGroup(`Docker image version`);
|
core.startGroup(`Docker image version`);
|
||||||
core.info(version.main || '');
|
core.info(version.main || '');
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
core.setOutput('version', version.main || '');
|
}
|
||||||
|
setOutput('version', version.main || '');
|
||||||
|
|
||||||
const tags: Array<string> = meta.tags();
|
// Docker tags
|
||||||
|
const tags: Array<string> = meta.getTags();
|
||||||
|
if (tags.length == 0) {
|
||||||
|
core.warning('No Docker tag has been generated. Check tags input.');
|
||||||
|
} else {
|
||||||
core.startGroup(`Docker tags`);
|
core.startGroup(`Docker tags`);
|
||||||
for (let tag of tags) {
|
for (let tag of tags) {
|
||||||
core.info(tag);
|
core.info(tag);
|
||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
core.setOutput('tags', tags.join(inputs.sepTags));
|
}
|
||||||
|
setOutput('tags', tags.join(inputs.sepTags));
|
||||||
|
|
||||||
const labels: Array<string> = meta.labels();
|
// Docker labels
|
||||||
|
const labels: Array<string> = meta.getLabels();
|
||||||
core.startGroup(`Docker labels`);
|
core.startGroup(`Docker labels`);
|
||||||
for (let label of labels) {
|
for (let label of labels) {
|
||||||
core.info(label);
|
core.info(label);
|
||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
core.setOutput('labels', labels.join(inputs.sepLabels));
|
setOutput('labels', labels.join(inputs.sepLabels));
|
||||||
|
|
||||||
|
// Bake definition file
|
||||||
|
const bakeFile: string = meta.getBakeFile();
|
||||||
|
core.startGroup(`Bake definition file`);
|
||||||
|
core.info(fs.readFileSync(bakeFile, 'utf8'));
|
||||||
|
core.endGroup();
|
||||||
|
setOutput('bake-file', bakeFile);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
336
src/meta.ts
336
src/meta.ts
@@ -1,7 +1,11 @@
|
|||||||
import * as handlebars from 'handlebars';
|
import * as handlebars from 'handlebars';
|
||||||
import * as moment from 'moment';
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
import moment from 'moment';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import {Inputs} from './context';
|
import {Inputs, tmpDir} from './context';
|
||||||
|
import * as tcl from './tag';
|
||||||
|
import * as fcl from './flavor';
|
||||||
import * as core from '@actions/core';
|
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';
|
||||||
@@ -9,7 +13,7 @@ import {ReposGetResponseData} from '@octokit/types';
|
|||||||
export interface Version {
|
export interface Version {
|
||||||
main: string | undefined;
|
main: string | undefined;
|
||||||
partial: string[];
|
partial: string[];
|
||||||
latest: boolean;
|
latest: boolean | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Meta {
|
export class Meta {
|
||||||
@@ -18,96 +22,263 @@ export class Meta {
|
|||||||
private readonly inputs: Inputs;
|
private readonly inputs: Inputs;
|
||||||
private readonly context: Context;
|
private readonly context: Context;
|
||||||
private readonly repo: ReposGetResponseData;
|
private readonly repo: ReposGetResponseData;
|
||||||
|
private readonly tags: tcl.Tag[];
|
||||||
|
private readonly flavor: fcl.Flavor;
|
||||||
private readonly date: Date;
|
private readonly date: Date;
|
||||||
|
|
||||||
constructor(inputs: Inputs, context: Context, repo: ReposGetResponseData) {
|
constructor(inputs: Inputs, context: Context, repo: ReposGetResponseData) {
|
||||||
this.inputs = inputs;
|
this.inputs = inputs;
|
||||||
if (!this.inputs.tagEdgeBranch) {
|
|
||||||
this.inputs.tagEdgeBranch = repo.default_branch;
|
|
||||||
}
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
|
this.tags = tcl.Transform(inputs.tags);
|
||||||
|
this.flavor = fcl.Transform(inputs.flavor);
|
||||||
this.date = new Date();
|
this.date = new Date();
|
||||||
this.version = this.getVersion();
|
this.version = this.getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
private getVersion(): Version {
|
private getVersion(): Version {
|
||||||
const currentDate = this.date;
|
|
||||||
let version: Version = {
|
let version: Version = {
|
||||||
main: undefined,
|
main: undefined,
|
||||||
partial: [],
|
partial: [],
|
||||||
latest: false
|
latest: undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
if (/schedule/.test(this.context.eventName)) {
|
for (const tag of this.tags) {
|
||||||
version.main = handlebars.compile(this.inputs.tagSchedule)({
|
if (!/true/i.test(tag.attrs['enable'])) {
|
||||||
date: function (format) {
|
|
||||||
return moment(currentDate).utc().format(format);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (/^refs\/tags\//.test(this.context.ref)) {
|
|
||||||
version.main = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
|
||||||
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;
|
continue;
|
||||||
}
|
}
|
||||||
version.partial.push(partial);
|
switch (tag.type) {
|
||||||
|
case tcl.Type.Schedule: {
|
||||||
|
version = this.procSchedule(version, tag);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
case tcl.Type.Semver: {
|
||||||
|
version = this.procSemver(version, tag);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (this.inputs.tagMatch) {
|
case tcl.Type.Match: {
|
||||||
let tagMatch;
|
version = this.procMatch(version, tag);
|
||||||
const isRegEx = this.inputs.tagMatch.match(/^\/(.+)\/(.*)$/);
|
break;
|
||||||
if (isRegEx) {
|
|
||||||
tagMatch = version.main.match(new RegExp(isRegEx[1], isRegEx[2]));
|
|
||||||
} else {
|
|
||||||
tagMatch = version.main.match(this.inputs.tagMatch);
|
|
||||||
}
|
}
|
||||||
if (tagMatch) {
|
case tcl.Type.Ref: {
|
||||||
version.main = tagMatch[this.inputs.tagMatchGroup];
|
if (tag.attrs['event'] == tcl.RefEvent.Branch) {
|
||||||
version.latest = this.inputs.tagLatest;
|
version = this.procRefBranch(version, tag);
|
||||||
|
} else if (tag.attrs['event'] == tcl.RefEvent.Tag) {
|
||||||
|
version = this.procRefTag(version, tag);
|
||||||
|
} else if (tag.attrs['event'] == tcl.RefEvent.PR) {
|
||||||
|
version = this.procRefPr(version, tag);
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
version.latest = this.inputs.tagLatest;
|
|
||||||
}
|
}
|
||||||
} else if (/^refs\/heads\//.test(this.context.ref)) {
|
case tcl.Type.Edge: {
|
||||||
version.main = this.context.ref.replace(/^refs\/heads\//g, '').replace(/[^a-zA-Z0-9._-]+/g, '-');
|
version = this.procEdge(version, tag);
|
||||||
if (this.inputs.tagEdge && this.inputs.tagEdgeBranch === version.main) {
|
break;
|
||||||
version.main = 'edge';
|
|
||||||
}
|
}
|
||||||
} else if (/^refs\/pull\//.test(this.context.ref)) {
|
case tcl.Type.Raw: {
|
||||||
version.main = `pr-${this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '')}`;
|
version = this.procRaw(version, tag);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case tcl.Type.Sha: {
|
||||||
|
version = this.procSha(version, tag);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
version.partial = version.partial.filter((item, index) => version.partial.indexOf(item) === index);
|
||||||
|
if (version.latest == undefined) {
|
||||||
|
version.latest = false;
|
||||||
|
}
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public tags(): Array<string> {
|
private procSchedule(version: Version, tag: tcl.Tag): Version {
|
||||||
|
if (!/schedule/.test(this.context.eventName)) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentDate = this.date;
|
||||||
|
const vraw = this.setValue(
|
||||||
|
handlebars.compile(tag.attrs['pattern'])({
|
||||||
|
date: function (format) {
|
||||||
|
return moment(currentDate).utc().format(format);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
tag
|
||||||
|
);
|
||||||
|
|
||||||
|
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||||
|
}
|
||||||
|
|
||||||
|
private procSemver(version: Version, tag: tcl.Tag): Version {
|
||||||
|
if (!/^refs\/tags\//.test(this.context.ref) && tag.attrs['value'].length == 0) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
let vraw: string;
|
||||||
|
if (tag.attrs['value'].length > 0) {
|
||||||
|
vraw = this.setGlobalExp(tag.attrs['value']);
|
||||||
|
} else {
|
||||||
|
vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
||||||
|
}
|
||||||
|
if (!semver.valid(vraw)) {
|
||||||
|
core.warning(`${vraw} is not a valid semver. More info: https://semver.org/`);
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
let latest: boolean = false;
|
||||||
|
const sver = semver.parse(vraw, {
|
||||||
|
includePrerelease: true
|
||||||
|
});
|
||||||
|
if (semver.prerelease(vraw)) {
|
||||||
|
vraw = this.setValue(handlebars.compile('{{version}}')(sver), tag);
|
||||||
|
} else {
|
||||||
|
vraw = this.setValue(handlebars.compile(tag.attrs['pattern'])(sver), tag);
|
||||||
|
latest = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true');
|
||||||
|
}
|
||||||
|
|
||||||
|
private procMatch(version: Version, tag: tcl.Tag): Version {
|
||||||
|
if (!/^refs\/tags\//.test(this.context.ref) && tag.attrs['value'].length == 0) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
let vraw: string;
|
||||||
|
if (tag.attrs['value'].length > 0) {
|
||||||
|
vraw = this.setGlobalExp(tag.attrs['value']);
|
||||||
|
} else {
|
||||||
|
vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
||||||
|
}
|
||||||
|
|
||||||
|
let latest: boolean = false;
|
||||||
|
let tmatch;
|
||||||
|
const isRegEx = tag.attrs['pattern'].match(/^\/(.+)\/(.*)$/);
|
||||||
|
if (isRegEx) {
|
||||||
|
tmatch = vraw.match(new RegExp(isRegEx[1], isRegEx[2]));
|
||||||
|
} else {
|
||||||
|
tmatch = vraw.match(tag.attrs['pattern']);
|
||||||
|
}
|
||||||
|
if (!tmatch) {
|
||||||
|
core.warning(`${tag.attrs['pattern']} does not match ${vraw}.`);
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
if (typeof tmatch[tag.attrs['group']] === 'undefined') {
|
||||||
|
core.warning(`Group ${tag.attrs['group']} does not exist for ${tag.attrs['pattern']} pattern.`);
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
vraw = this.setValue(tmatch[tag.attrs['group']], tag);
|
||||||
|
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? true : this.flavor.latest == 'true');
|
||||||
|
}
|
||||||
|
|
||||||
|
private procRefBranch(version: Version, tag: tcl.Tag): Version {
|
||||||
|
if (!/^refs\/heads\//.test(this.context.ref)) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
const vraw = this.setValue(this.context.ref.replace(/^refs\/heads\//g, '').replace(/[^a-zA-Z0-9._-]+/g, '-'), tag);
|
||||||
|
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||||
|
}
|
||||||
|
|
||||||
|
private procRefTag(version: Version, tag: tcl.Tag): Version {
|
||||||
|
if (!/^refs\/tags\//.test(this.context.ref)) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
const vraw = this.setValue(this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-'), tag);
|
||||||
|
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? true : this.flavor.latest == 'true');
|
||||||
|
}
|
||||||
|
|
||||||
|
private procRefPr(version: Version, tag: tcl.Tag): Version {
|
||||||
|
if (!/^refs\/pull\//.test(this.context.ref)) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
const vraw = this.setValue(this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, ''), tag);
|
||||||
|
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||||
|
}
|
||||||
|
|
||||||
|
private procEdge(version: Version, tag: tcl.Tag): Version {
|
||||||
|
if (!/^refs\/heads\//.test(this.context.ref)) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
let val = this.context.ref.replace(/^refs\/heads\//g, '').replace(/[^a-zA-Z0-9._-]+/g, '-');
|
||||||
|
if (tag.attrs['branch'].length == 0) {
|
||||||
|
tag.attrs['branch'] = this.repo.default_branch;
|
||||||
|
}
|
||||||
|
if (tag.attrs['branch'] === val) {
|
||||||
|
val = 'edge';
|
||||||
|
}
|
||||||
|
|
||||||
|
const vraw = this.setValue(val, tag);
|
||||||
|
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||||
|
}
|
||||||
|
|
||||||
|
private procRaw(version: Version, tag: tcl.Tag): Version {
|
||||||
|
const vraw = this.setValue(this.setGlobalExp(tag.attrs['value']), tag);
|
||||||
|
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||||
|
}
|
||||||
|
|
||||||
|
private procSha(version: Version, tag: tcl.Tag): Version {
|
||||||
|
if (!this.context.sha) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
const vraw = this.setValue(this.context.sha.substr(0, 7), tag);
|
||||||
|
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||||
|
}
|
||||||
|
|
||||||
|
private static setVersion(version: Version, val: string, latest: boolean): Version {
|
||||||
|
if (val.length == 0) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
if (version.main == undefined) {
|
||||||
|
version.main = val;
|
||||||
|
} else if (val !== version.main) {
|
||||||
|
version.partial.push(val);
|
||||||
|
}
|
||||||
|
if (version.latest == undefined) {
|
||||||
|
version.latest = latest;
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
private setValue(val: string, tag: tcl.Tag): string {
|
||||||
|
if (tag.attrs.hasOwnProperty('prefix')) {
|
||||||
|
val = `${this.setGlobalExp(tag.attrs['prefix'])}${val}`;
|
||||||
|
} else if (this.flavor.prefix.length > 0) {
|
||||||
|
val = `${this.setGlobalExp(this.flavor.prefix)}${val}`;
|
||||||
|
}
|
||||||
|
if (tag.attrs.hasOwnProperty('suffix')) {
|
||||||
|
val = `${val}${this.setGlobalExp(tag.attrs['suffix'])}`;
|
||||||
|
} else if (this.flavor.suffix.length > 0) {
|
||||||
|
val = `${val}${this.setGlobalExp(this.flavor.suffix)}`;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
private setGlobalExp(val): string {
|
||||||
|
const ctx = this.context;
|
||||||
|
return handlebars.compile(val)({
|
||||||
|
branch: function () {
|
||||||
|
if (!/^refs\/heads\//.test(ctx.ref)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return ctx.ref.replace(/^refs\/heads\//g, '').replace(/[^a-zA-Z0-9._-]+/g, '-');
|
||||||
|
},
|
||||||
|
tag: function () {
|
||||||
|
if (!/^refs\/tags\//.test(ctx.ref)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return ctx.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
||||||
|
},
|
||||||
|
sha: function () {
|
||||||
|
return ctx.sha.substr(0, 7);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public getTags(): Array<string> {
|
||||||
if (!this.version.main) {
|
if (!this.version.main) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -122,15 +293,12 @@ export class Meta {
|
|||||||
if (this.version.latest) {
|
if (this.version.latest) {
|
||||||
tags.push(`${imageLc}:latest`);
|
tags.push(`${imageLc}:latest`);
|
||||||
}
|
}
|
||||||
if (this.context.sha && this.inputs.tagSha) {
|
|
||||||
tags.push(`${imageLc}:sha-${this.context.sha.substr(0, 7)}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public labels(): Array<string> {
|
public getLabels(): Array<string> {
|
||||||
return [
|
let labels: Array<string> = [
|
||||||
`org.opencontainers.image.title=${this.repo.name || ''}`,
|
`org.opencontainers.image.title=${this.repo.name || ''}`,
|
||||||
`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 || ''}`,
|
||||||
@@ -140,5 +308,41 @@ export class Meta {
|
|||||||
`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 || ''}`
|
||||||
];
|
];
|
||||||
|
labels.push(...this.inputs.labels);
|
||||||
|
return labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getBakeFile(): string {
|
||||||
|
let jsonLabels = {};
|
||||||
|
for (let label of this.getLabels()) {
|
||||||
|
const matches = label.match(/([^=]*)=(.*)/);
|
||||||
|
if (!matches) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
jsonLabels[matches[1]] = matches[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
const bakeFile = path.join(tmpDir(), 'ghaction-docker-meta-bake.json').split(path.sep).join(path.posix.sep);
|
||||||
|
fs.writeFileSync(
|
||||||
|
bakeFile,
|
||||||
|
JSON.stringify(
|
||||||
|
{
|
||||||
|
target: {
|
||||||
|
[this.inputs.bakeTarget]: {
|
||||||
|
tags: this.getTags(),
|
||||||
|
labels: jsonLabels,
|
||||||
|
args: {
|
||||||
|
DOCKER_META_IMAGES: this.inputs.images.join(','),
|
||||||
|
DOCKER_META_VERSION: this.version.main
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
2
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return bakeFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
193
src/tag.ts
Normal file
193
src/tag.ts
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
import csvparse from 'csv-parse/lib/sync';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
|
export enum Type {
|
||||||
|
Schedule = 'schedule',
|
||||||
|
Semver = 'semver',
|
||||||
|
Match = 'match',
|
||||||
|
Edge = 'edge',
|
||||||
|
Ref = 'ref',
|
||||||
|
Raw = 'raw',
|
||||||
|
Sha = 'sha'
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum RefEvent {
|
||||||
|
Branch = 'branch',
|
||||||
|
Tag = 'tag',
|
||||||
|
PR = 'pr'
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Tag {
|
||||||
|
public type?: Type;
|
||||||
|
public attrs: Record<string, string>;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.attrs = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
public toString(): string {
|
||||||
|
const out: string[] = [`type=${this.type}`];
|
||||||
|
for (let attr in this.attrs) {
|
||||||
|
out.push(`${attr}=${this.attrs[attr]}`);
|
||||||
|
}
|
||||||
|
return out.join(',');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DefaultPriorities: Record<Type, string> = {
|
||||||
|
[Type.Schedule]: '1000',
|
||||||
|
[Type.Semver]: '900',
|
||||||
|
[Type.Match]: '800',
|
||||||
|
[Type.Edge]: '700',
|
||||||
|
[Type.Ref]: '600',
|
||||||
|
[Type.Raw]: '200',
|
||||||
|
[Type.Sha]: '100'
|
||||||
|
};
|
||||||
|
|
||||||
|
export function Transform(inputs: string[]): Tag[] {
|
||||||
|
const tags: Tag[] = [];
|
||||||
|
if (inputs.length == 0) {
|
||||||
|
// prettier-ignore
|
||||||
|
inputs = [
|
||||||
|
`type=schedule`,
|
||||||
|
`type=ref,event=${RefEvent.Branch}`,
|
||||||
|
`type=ref,event=${RefEvent.Tag}`,
|
||||||
|
`type=ref,event=${RefEvent.PR}`
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const input of inputs) {
|
||||||
|
tags.push(Parse(input));
|
||||||
|
}
|
||||||
|
const sorted = tags.sort((tag1, tag2) => {
|
||||||
|
if (Number(tag1.attrs['priority']) < Number(tag2.attrs['priority'])) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (Number(tag1.attrs['priority']) > Number(tag2.attrs['priority'])) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
core.startGroup(`Processing tags input`);
|
||||||
|
for (const tag of sorted) {
|
||||||
|
core.info(tag.toString());
|
||||||
|
}
|
||||||
|
core.endGroup();
|
||||||
|
|
||||||
|
return sorted;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Parse(s: string): Tag {
|
||||||
|
const fields = csvparse(s, {
|
||||||
|
relaxColumnCount: true,
|
||||||
|
skipLinesWithEmptyValues: true
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
const tag = new Tag();
|
||||||
|
for (const field of fields) {
|
||||||
|
const parts = field.toString().split('=', 2);
|
||||||
|
if (parts.length == 1) {
|
||||||
|
tag.attrs['value'] = parts[0].trim();
|
||||||
|
} else {
|
||||||
|
const key = parts[0].trim().toLowerCase();
|
||||||
|
const value = parts[1].trim();
|
||||||
|
switch (key) {
|
||||||
|
case 'type': {
|
||||||
|
if (!Object.values(Type).includes(value)) {
|
||||||
|
throw new Error(`Unknown type attribute: ${value}`);
|
||||||
|
}
|
||||||
|
tag.type = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
tag.attrs[key] = value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag.type == undefined) {
|
||||||
|
tag.type = Type.Raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (tag.type) {
|
||||||
|
case Type.Schedule: {
|
||||||
|
if (!tag.attrs.hasOwnProperty('pattern')) {
|
||||||
|
tag.attrs['pattern'] = 'nightly';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Type.Semver: {
|
||||||
|
if (!tag.attrs.hasOwnProperty('pattern')) {
|
||||||
|
throw new Error(`Missing pattern attribute for ${s}`);
|
||||||
|
}
|
||||||
|
if (!tag.attrs.hasOwnProperty('value')) {
|
||||||
|
tag.attrs['value'] = '';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Type.Match: {
|
||||||
|
if (!tag.attrs.hasOwnProperty('pattern')) {
|
||||||
|
throw new Error(`Missing pattern attribute for ${s}`);
|
||||||
|
}
|
||||||
|
if (!tag.attrs.hasOwnProperty('group')) {
|
||||||
|
tag.attrs['group'] = '0';
|
||||||
|
}
|
||||||
|
if (isNaN(+tag.attrs['group'])) {
|
||||||
|
throw new Error(`Invalid match group for ${s}`);
|
||||||
|
}
|
||||||
|
if (!tag.attrs.hasOwnProperty('value')) {
|
||||||
|
tag.attrs['value'] = '';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Type.Edge: {
|
||||||
|
if (!tag.attrs.hasOwnProperty('branch')) {
|
||||||
|
tag.attrs['branch'] = '';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Type.Ref: {
|
||||||
|
if (!tag.attrs.hasOwnProperty('event')) {
|
||||||
|
throw new Error(`Missing event attribute for ${s}`);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
!Object.keys(RefEvent)
|
||||||
|
.map(k => RefEvent[k])
|
||||||
|
.includes(tag.attrs['event'])
|
||||||
|
) {
|
||||||
|
throw new Error(`Invalid event for ${s}`);
|
||||||
|
}
|
||||||
|
if (tag.attrs['event'] == RefEvent.PR && !tag.attrs.hasOwnProperty('prefix')) {
|
||||||
|
tag.attrs['prefix'] = 'pr-';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Type.Raw: {
|
||||||
|
if (!tag.attrs.hasOwnProperty('value')) {
|
||||||
|
throw new Error(`Missing value attribute for ${s}`);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Type.Sha: {
|
||||||
|
if (!tag.attrs.hasOwnProperty('prefix')) {
|
||||||
|
tag.attrs['prefix'] = 'sha-';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tag.attrs.hasOwnProperty('enable')) {
|
||||||
|
tag.attrs['enable'] = 'true';
|
||||||
|
}
|
||||||
|
if (!tag.attrs.hasOwnProperty('priority')) {
|
||||||
|
tag.attrs['priority'] = DefaultPriorities[tag.type];
|
||||||
|
}
|
||||||
|
if (!['true', 'false'].includes(tag.attrs['enable'])) {
|
||||||
|
throw new Error(`Invalid value for enable attribute: ${tag.attrs['enable']}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
38
test/docker-bake.hcl
Normal file
38
test/docker-bake.hcl
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
target "ghaction-docker-meta" {}
|
||||||
|
|
||||||
|
group "default" {
|
||||||
|
targets = ["db", "app"]
|
||||||
|
}
|
||||||
|
|
||||||
|
group "release" {
|
||||||
|
targets = ["db", "app-plus"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "db" {
|
||||||
|
context = "./test"
|
||||||
|
tags = ["docker.io/tonistiigi/db"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "app" {
|
||||||
|
inherits = ["ghaction-docker-meta"]
|
||||||
|
context = "./test"
|
||||||
|
dockerfile = "Dockerfile"
|
||||||
|
args = {
|
||||||
|
name = "foo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
target "cross" {
|
||||||
|
platforms = [
|
||||||
|
"linux/amd64",
|
||||||
|
"linux/arm64",
|
||||||
|
"linux/386"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "app-plus" {
|
||||||
|
inherits = ["app", "cross"]
|
||||||
|
args = {
|
||||||
|
IAMPLUS = "true"
|
||||||
|
}
|
||||||
|
}
|
@@ -11,9 +11,11 @@
|
|||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"esModuleInterop": false,
|
"esModuleInterop": true,
|
||||||
"resolveJsonModule": true,
|
|
||||||
"sourceMap": true
|
"sourceMap": true
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "**/*.test.ts"]
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"**/*.test.ts"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
59
yarn.lock
59
yarn.lock
@@ -2,10 +2,10 @@
|
|||||||
# yarn lockfile v1
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
"@actions/core@^1.2.6":
|
"@actions/core@^1.2.7":
|
||||||
version "1.2.6"
|
version "1.2.7"
|
||||||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09"
|
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.7.tgz#594f8c45b213f0146e4be7eda8ae5cf4e198e5ab"
|
||||||
integrity sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==
|
integrity sha512-kzLFD5BgEvq6ubcxdgPbRKGD2Qrgya/5j+wh4LZzqT915I0V3rED+MvjH6NXghbvk1MXknpNNQ3uKjXSEN00Ig==
|
||||||
|
|
||||||
"@actions/github@^4.0.0":
|
"@actions/github@^4.0.0":
|
||||||
version "4.0.0"
|
version "4.0.0"
|
||||||
@@ -1176,6 +1176,11 @@ cssstyle@^2.2.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
cssom "~0.3.6"
|
cssom "~0.3.6"
|
||||||
|
|
||||||
|
csv-parse@^4.15.4:
|
||||||
|
version "4.15.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-4.15.4.tgz#ad1ec62aaf71a642982dfcb81f1848184d691db5"
|
||||||
|
integrity sha512-OdBbFc0yZhOm17lSxqkirrHlFFVpKRT0wp4DAGoJelsP3LbGzV9LNr7XmM/lrr0uGkCtaqac9UhP8PDHXOAbMg==
|
||||||
|
|
||||||
dashdash@^1.12.0:
|
dashdash@^1.12.0:
|
||||||
version "1.14.1"
|
version "1.14.1"
|
||||||
resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
|
resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
|
||||||
@@ -1622,10 +1627,10 @@ growly@^1.3.0:
|
|||||||
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
|
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
|
||||||
integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=
|
integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=
|
||||||
|
|
||||||
handlebars@^4.7.6:
|
handlebars@^4.7.7:
|
||||||
version "4.7.6"
|
version "4.7.7"
|
||||||
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.6.tgz#d4c05c1baf90e9945f77aa68a7a219aa4a7df74e"
|
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.7.tgz#9ce33416aad02dbd6c8fafa8240d5d98004945a1"
|
||||||
integrity sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==
|
integrity sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==
|
||||||
dependencies:
|
dependencies:
|
||||||
minimist "^1.2.5"
|
minimist "^1.2.5"
|
||||||
neo-async "^2.6.0"
|
neo-async "^2.6.0"
|
||||||
@@ -1696,9 +1701,9 @@ has@^1.0.3:
|
|||||||
function-bind "^1.1.1"
|
function-bind "^1.1.1"
|
||||||
|
|
||||||
hosted-git-info@^2.1.4:
|
hosted-git-info@^2.1.4:
|
||||||
version "2.8.8"
|
version "2.8.9"
|
||||||
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
|
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
|
||||||
integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==
|
integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==
|
||||||
|
|
||||||
html-encoding-sniffer@^2.0.1:
|
html-encoding-sniffer@^2.0.1:
|
||||||
version "2.0.1"
|
version "2.0.1"
|
||||||
@@ -2541,9 +2546,9 @@ lodash.sortby@^4.7.0:
|
|||||||
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
|
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
|
||||||
|
|
||||||
lodash@^4.17.19:
|
lodash@^4.17.19:
|
||||||
version "4.17.20"
|
version "4.17.21"
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||||
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
|
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||||
|
|
||||||
lru-cache@^6.0.0:
|
lru-cache@^6.0.0:
|
||||||
version "6.0.0"
|
version "6.0.0"
|
||||||
@@ -2720,9 +2725,9 @@ node-modules-regexp@^1.0.0:
|
|||||||
integrity sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=
|
integrity sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=
|
||||||
|
|
||||||
node-notifier@^8.0.0:
|
node-notifier@^8.0.0:
|
||||||
version "8.0.0"
|
version "8.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-8.0.0.tgz#a7eee2d51da6d0f7ff5094bc7108c911240c1620"
|
resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-8.0.1.tgz#f86e89bbc925f2b068784b31f382afdc6ca56be1"
|
||||||
integrity sha512-46z7DUmcjoYdaWyXouuFNNfUo6eFa94t23c53c+lG/9Cvauk4a98rAUp9672X5dxGdQmLpPzTxzu8f/OeEPaFA==
|
integrity sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==
|
||||||
dependencies:
|
dependencies:
|
||||||
growly "^1.3.0"
|
growly "^1.3.0"
|
||||||
is-wsl "^2.2.0"
|
is-wsl "^2.2.0"
|
||||||
@@ -3170,10 +3175,10 @@ 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.3.4:
|
semver@7.x, semver@^7.3.2, semver@^7.3.5:
|
||||||
version "7.3.4"
|
version "7.3.5"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
|
||||||
integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==
|
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
lru-cache "^6.0.0"
|
lru-cache "^6.0.0"
|
||||||
|
|
||||||
@@ -3662,9 +3667,9 @@ uuid@^3.3.2:
|
|||||||
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
|
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
|
||||||
|
|
||||||
uuid@^8.3.0:
|
uuid@^8.3.0:
|
||||||
version "8.3.1"
|
version "8.3.2"
|
||||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.1.tgz#2ba2e6ca000da60fce5a196954ab241131e05a31"
|
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
||||||
integrity sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==
|
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
|
||||||
|
|
||||||
v8-to-istanbul@^6.0.1:
|
v8-to-istanbul@^6.0.1:
|
||||||
version "6.0.1"
|
version "6.0.1"
|
||||||
@@ -3813,9 +3818,9 @@ xmlchars@^2.2.0:
|
|||||||
integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==
|
integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==
|
||||||
|
|
||||||
y18n@^4.0.0:
|
y18n@^4.0.0:
|
||||||
version "4.0.0"
|
version "4.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
|
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4"
|
||||||
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==
|
integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==
|
||||||
|
|
||||||
yallist@^4.0.0:
|
yallist@^4.0.0:
|
||||||
version "4.0.0"
|
version "4.0.0"
|
||||||
|
Reference in New Issue
Block a user