mirror of
https://github.com/docker/metadata-action.git
synced 2026-03-04 07:58:16 +00:00
Compare commits
104 Commits
v5.7.0
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de593939c1 | ||
|
|
bc6c9452f7 | ||
|
|
cb50be4508 | ||
|
|
8fd95d6f08 | ||
|
|
a4e219a90d | ||
|
|
76c27c49eb | ||
|
|
1ea5d4f1b0 | ||
|
|
91c3fe061e | ||
|
|
f332e46fa5 | ||
|
|
51b601f22d | ||
|
|
8480620af8 | ||
|
|
8e71445576 | ||
|
|
f57c915b64 | ||
|
|
d92a8d0b86 | ||
|
|
cf6a6ce0f7 | ||
|
|
d5be006250 | ||
|
|
a60f0f62b5 | ||
|
|
10f4f1aaa5 | ||
|
|
70c914a6f8 | ||
|
|
ed95091677 | ||
|
|
57670b6268 | ||
|
|
d636a41a2f | ||
|
|
9c747a7ed1 | ||
|
|
c98baa7757 | ||
|
|
ad1f8b1f99 | ||
|
|
f0a4bc3c2d | ||
|
|
9b6cf6ec37 | ||
|
|
c299e40c65 | ||
|
|
f015d7914a | ||
|
|
121bcc2ca8 | ||
|
|
f7b6bf41b9 | ||
|
|
0b95c6b860 | ||
|
|
17f70d7525 | ||
|
|
afd7e6d7bb | ||
|
|
602aff8e11 | ||
|
|
aecb1a49a5 | ||
|
|
8d8c7c12f7 | ||
|
|
15bd03a177 | ||
|
|
fdba5868fb | ||
|
|
318604b99e | ||
|
|
49c0a55d55 | ||
|
|
486229e3f4 | ||
|
|
f02aeab1ee | ||
|
|
beafb97305 | ||
|
|
3ff819c6c5 | ||
|
|
05838e9769 | ||
|
|
43fa4ac0d3 | ||
|
|
b3120f2f18 | ||
|
|
1f469d21ee | ||
|
|
b0a2bcfe7b | ||
|
|
14973dfd4b | ||
|
|
dae123c2bf | ||
|
|
fdb90a51ae | ||
|
|
e5afe339d8 | ||
|
|
17e37c2a42 | ||
|
|
aa0be5b84c | ||
|
|
136a4a23fe | ||
|
|
5f9eb12581 | ||
|
|
be25a4ce07 | ||
|
|
eced061233 | ||
|
|
e7f20f98b1 | ||
|
|
95bdd37b1f | ||
|
|
3fb4efdf45 | ||
|
|
f31cd74edd | ||
|
|
840a42f4cf | ||
|
|
ada8aa8ca0 | ||
|
|
3fa6bb33cb | ||
|
|
8aa9733355 | ||
|
|
d87caff40c | ||
|
|
83e4951424 | ||
|
|
9efc8723fe | ||
|
|
ec2c9a30cf | ||
|
|
e427fa1e40 | ||
|
|
032a4b3bda | ||
|
|
06e11bf926 | ||
|
|
c1e51972af | ||
|
|
89dd65a569 | ||
|
|
699ee45cf1 | ||
|
|
e0542a6360 | ||
|
|
b7facdfcef | ||
|
|
81c60dfb8b | ||
|
|
de1119515d | ||
|
|
2f9c64b1b1 | ||
|
|
510f746975 | ||
|
|
2bc3f4e0f1 | ||
|
|
f0cfcb57f6 | ||
|
|
be19121bfd | ||
|
|
c1eb0314a3 | ||
|
|
b798ed8388 | ||
|
|
07d42e0b4f | ||
|
|
495d5ce528 | ||
|
|
54b10fa1b6 | ||
|
|
c49a1eee09 | ||
|
|
f37a3b6e88 | ||
|
|
85eb7c9324 | ||
|
|
a1c21022b0 | ||
|
|
6547919405 | ||
|
|
2e80e58e70 | ||
|
|
a51254e5fa | ||
|
|
dee3324b00 | ||
|
|
418e4b98bf | ||
|
|
e8ece87dc8 | ||
|
|
12d9b9a905 | ||
|
|
c88acc31ec |
@@ -1,3 +0,0 @@
|
|||||||
/dist/**
|
|
||||||
/coverage/**
|
|
||||||
/node_modules/**
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"env": {
|
|
||||||
"node": true,
|
|
||||||
"es6": true,
|
|
||||||
"jest": true
|
|
||||||
},
|
|
||||||
"extends": [
|
|
||||||
"eslint:recommended",
|
|
||||||
"plugin:@typescript-eslint/eslint-recommended",
|
|
||||||
"plugin:@typescript-eslint/recommended",
|
|
||||||
"plugin:jest/recommended",
|
|
||||||
"plugin:prettier/recommended"
|
|
||||||
],
|
|
||||||
"parser": "@typescript-eslint/parser",
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 2023,
|
|
||||||
"sourceType": "module"
|
|
||||||
},
|
|
||||||
"plugins": [
|
|
||||||
"@typescript-eslint",
|
|
||||||
"jest",
|
|
||||||
"prettier"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
43
.github/workflows/ci.yml
vendored
43
.github/workflows/ci.yml
vendored
@@ -31,7 +31,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -43,7 +43,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -80,7 +80,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -116,7 +116,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -150,7 +150,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -181,7 +181,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -204,7 +204,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -225,7 +225,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -255,7 +255,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -278,13 +278,14 @@ jobs:
|
|||||||
type=raw,value=gexp-tag-{{tag}}
|
type=raw,value=gexp-tag-{{tag}}
|
||||||
type=raw,value=gexp-baseref-{{base_ref}}
|
type=raw,value=gexp-baseref-{{base_ref}}
|
||||||
type=raw,value=gexp-defbranch,enable={{is_default_branch}}
|
type=raw,value=gexp-defbranch,enable={{is_default_branch}}
|
||||||
|
type=raw,value=gexp-notdefbranch,enable={{is_not_default_branch}}
|
||||||
|
|
||||||
json:
|
json:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -319,7 +320,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -367,7 +368,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -412,7 +413,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -430,7 +431,7 @@ jobs:
|
|||||||
sep-tags: ${{ matrix.sep }}
|
sep-tags: ${{ matrix.sep }}
|
||||||
-
|
-
|
||||||
name: Tags
|
name: Tags
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v8
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
console.log(`${{ steps.meta.outputs.tags }}`);
|
console.log(`${{ steps.meta.outputs.tags }}`);
|
||||||
@@ -440,7 +441,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -479,7 +480,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
@@ -503,7 +504,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -544,7 +545,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -570,7 +571,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -603,7 +604,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -627,7 +628,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Dump context
|
name: Dump context
|
||||||
uses: crazy-max/ghaction-dump-context@v2
|
uses: crazy-max/ghaction-dump-context@v2
|
||||||
|
|||||||
17
.github/workflows/pr-assign-author.yml
vendored
Normal file
17
.github/workflows/pr-assign-author.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
name: pr-assign-author
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- reopened
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run:
|
||||||
|
uses: crazy-max/.github/.github/workflows/pr-assign-author.yml@1b673f36fad86812f538c1df9794904038a23cbf
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: write
|
||||||
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Publish
|
name: Publish
|
||||||
uses: actions/publish-immutable-action@v0.0.4
|
uses: actions/publish-immutable-action@v0.0.4
|
||||||
|
|||||||
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
@@ -15,14 +15,18 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Test
|
name: Test
|
||||||
uses: docker/bake-action@v6
|
uses: docker/bake-action@v6
|
||||||
with:
|
with:
|
||||||
|
source: .
|
||||||
targets: test
|
targets: test
|
||||||
-
|
-
|
||||||
name: Upload coverage
|
name: Upload coverage
|
||||||
uses: codecov/codecov-action@v5
|
uses: codecov/codecov-action@v5
|
||||||
with:
|
with:
|
||||||
file: ./coverage/clover.xml
|
files: ./coverage/clover.xml
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|||||||
49
.github/workflows/update-dist.yml
vendored
Normal file
49
.github/workflows/update-dist.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
name: update-dist
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-dist:
|
||||||
|
if: github.actor == 'dependabot[bot]'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: GitHub auth token from GitHub App
|
||||||
|
id: docker-read-app
|
||||||
|
uses: actions/create-github-app-token@v2
|
||||||
|
with:
|
||||||
|
app-id: ${{ secrets.GHACTIONS_REPO_WRITE_APP_ID }}
|
||||||
|
private-key: ${{ secrets.GHACTIONS_REPO_WRITE_APP_PRIVATE_KEY }}
|
||||||
|
owner: docker
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.ref }}
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ steps.docker-read-app.outputs.token || github.token }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: docker/bake-action@v6
|
||||||
|
with:
|
||||||
|
source: .
|
||||||
|
targets: build
|
||||||
|
-
|
||||||
|
name: Commit and push dist
|
||||||
|
run: |
|
||||||
|
if [ -n "$(git status --porcelain -- dist)" ]; then
|
||||||
|
(
|
||||||
|
set -x
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git add dist
|
||||||
|
git commit -m "chore: update generated content"
|
||||||
|
git push
|
||||||
|
)
|
||||||
|
else
|
||||||
|
echo "No changes in dist"
|
||||||
|
fi
|
||||||
2
.github/workflows/validate.yml
vendored
2
.github/workflows/validate.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: List targets
|
name: List targets
|
||||||
id: generate
|
id: generate
|
||||||
|
|||||||
@@ -6,6 +6,5 @@
|
|||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"trailingComma": "none",
|
"trailingComma": "none",
|
||||||
"bracketSpacing": false,
|
"bracketSpacing": false,
|
||||||
"arrowParens": "avoid",
|
"arrowParens": "avoid"
|
||||||
"parser": "typescript"
|
|
||||||
}
|
}
|
||||||
|
|||||||
541
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
541
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
vendored
File diff suppressed because one or more lines are too long
12
.yarnrc.yml
12
.yarnrc.yml
@@ -1,3 +1,9 @@
|
|||||||
|
# https://yarnpkg.com/configuration/yarnrc
|
||||||
|
|
||||||
|
compressionLevel: mixed
|
||||||
|
enableGlobalCache: false
|
||||||
|
enableHardenedMode: true
|
||||||
|
|
||||||
logFilters:
|
logFilters:
|
||||||
- code: YN0013
|
- code: YN0013
|
||||||
level: discard
|
level: discard
|
||||||
@@ -5,9 +11,7 @@ logFilters:
|
|||||||
level: discard
|
level: discard
|
||||||
- code: YN0076
|
- code: YN0076
|
||||||
level: discard
|
level: discard
|
||||||
|
- code: YN0086
|
||||||
|
level: discard
|
||||||
|
|
||||||
nodeLinker: node-modules
|
nodeLinker: node-modules
|
||||||
|
|
||||||
plugins:
|
|
||||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
|
||||||
spec: "@yarnpkg/plugin-interactive-tools"
|
|
||||||
|
|||||||
74
README.md
74
README.md
@@ -44,6 +44,7 @@ ___
|
|||||||
* [`{{sha}}`](#sha)
|
* [`{{sha}}`](#sha)
|
||||||
* [`{{base_ref}}`](#base_ref)
|
* [`{{base_ref}}`](#base_ref)
|
||||||
* [`{{is_default_branch}}`](#is_default_branch)
|
* [`{{is_default_branch}}`](#is_default_branch)
|
||||||
|
* [`{{is_not_default_branch}}`](#is_not_default_branch)
|
||||||
* [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone)
|
* [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone)
|
||||||
* [`{{commit_date '<format>' tz='<timezone>'}}`](#commit_date-format-tztimezone)
|
* [`{{commit_date '<format>' tz='<timezone>'}}`](#commit_date-format-tztimezone)
|
||||||
* [Major version zero](#major-version-zero)
|
* [Major version zero](#major-version-zero)
|
||||||
@@ -76,7 +77,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
@@ -130,7 +131,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
-
|
-
|
||||||
name: Docker meta
|
name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
@@ -283,6 +284,7 @@ similar to the previous one:
|
|||||||
|
|
||||||
The following inputs can be used as `step.with` keys:
|
The following inputs can be used as `step.with` keys:
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
> `List` type is a newline-delimited string
|
> `List` type is a newline-delimited string
|
||||||
> ```yaml
|
> ```yaml
|
||||||
> labels: |
|
> labels: |
|
||||||
@@ -312,6 +314,7 @@ The following outputs are available:
|
|||||||
|-------------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|-------------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `version` | String | Docker image version |
|
| `version` | String | Docker image version |
|
||||||
| `tags` | String | Docker tags |
|
| `tags` | String | Docker tags |
|
||||||
|
| `tag-names` | String | Docker tag names without image base name |
|
||||||
| `labels` | String | Docker labels |
|
| `labels` | String | Docker labels |
|
||||||
| `annotations` | String | [Annotations](https://github.com/moby/buildkit/blob/master/docs/annotations.md) |
|
| `annotations` | String | [Annotations](https://github.com/moby/buildkit/blob/master/docs/annotations.md) |
|
||||||
| `json` | String | JSON output of tags and labels |
|
| `json` | String | JSON output of tags and labels |
|
||||||
@@ -461,7 +464,7 @@ tags: |
|
|||||||
# handlebars
|
# handlebars
|
||||||
type=schedule,pattern={{date 'YYYYMMDD'}}
|
type=schedule,pattern={{date 'YYYYMMDD'}}
|
||||||
# handlebars with timezone
|
# handlebars with timezone
|
||||||
type=schedule,pattern={{date 'YYYYMMDD-hhmmss' tz='Asia/Tokyo'}}
|
type=schedule,pattern={{date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}
|
||||||
```
|
```
|
||||||
|
|
||||||
Will be used on [schedule event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule).
|
Will be used on [schedule event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule).
|
||||||
@@ -493,6 +496,8 @@ tags: |
|
|||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
# use custom value instead of git tag
|
# use custom value instead of git tag
|
||||||
type=semver,pattern={{version}},value=v1.0.0
|
type=semver,pattern={{version}},value=v1.0.0
|
||||||
|
# use custom value and match part of it
|
||||||
|
type=semver,pattern={{version}},value=p1/v1.0.0,match=v(\d.\d.\d)$
|
||||||
```
|
```
|
||||||
|
|
||||||
Will be used on a [push tag event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push)
|
Will be used on a [push tag event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push)
|
||||||
@@ -508,18 +513,21 @@ with the following expressions:
|
|||||||
* `minor` ; minor version identifier
|
* `minor` ; minor version identifier
|
||||||
* `patch` ; patch version identifier
|
* `patch` ; patch version identifier
|
||||||
|
|
||||||
| Git tag | Pattern | Output |
|
| Git tag | Pattern | Match | Output |
|
||||||
|--------------------|----------------------------------------------------------|----------------------|
|
|------------------|-----------------------|----------------|------------------|
|
||||||
| `v1.2.3` | `{{raw}}` | `v1.2.3` |
|
| `v1.2.3` | `{{raw}}` | | `v1.2.3` |
|
||||||
| `v1.2.3` | `{{version}}` | `1.2.3` |
|
| `v1.2.3` | `{{version}}` | | `1.2.3` |
|
||||||
| `v1.2.3` | `{{major}}.{{minor}}` | `1.2` |
|
| `v1.2.3` | `{{major}}.{{minor}}` | | `1.2` |
|
||||||
| `v1.2.3` | `v{{major}}` | `v1` |
|
| `v1.2.3` | `v{{major}}` | | `v1` |
|
||||||
| `v1.2.3` | `{{minor}}` | `2` |
|
| `v1.2.3` | `{{minor}}` | | `2` |
|
||||||
| `v1.2.3` | `{{patch}}` | `3` |
|
| `v1.2.3` | `{{patch}}` | | `3` |
|
||||||
| `v2.0.8-beta.67` | `{{raw}}` | `v2.0.8-beta.67` |
|
| `p1/v1.2.3` | `{{version}}` | `v(\d.\d.\d)$` | `1.2.3` |
|
||||||
| `v2.0.8-beta.67` | `{{version}}` | `2.0.8-beta.67` |
|
| `v2.0.8-beta.67` | `{{raw}}` | | `v2.0.8-beta.67` |
|
||||||
| `v2.0.8-beta.67` | `{{major}}.{{minor}}` | `2.0.8-beta.67`* |
|
| `v2.0.8-beta.67` | `{{version}}` | | `2.0.8-beta.67` |
|
||||||
|
| `v2.0.8-beta.67` | `{{major}}` | | `2.0.8-beta.67`* |
|
||||||
|
| `v2.0.8-beta.67` | `{{major}}.{{minor}}` | | `2.0.8-beta.67`* |
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
> *Pre-release (rc, beta, alpha) will only extend `{{version}}` (or `{{raw}}`
|
> *Pre-release (rc, beta, alpha) will only extend `{{version}}` (or `{{raw}}`
|
||||||
> if specified) as tag because they are updated frequently, and contain many
|
> if specified) as tag because they are updated frequently, and contain many
|
||||||
> breaking changes that are (by the author's design) not yet fit for public
|
> breaking changes that are (by the author's design) not yet fit for public
|
||||||
@@ -529,7 +537,7 @@ Extended attributes and default values:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
tags: |
|
tags: |
|
||||||
type=semver,enable=true,priority=900,prefix=,suffix=,pattern=,value=
|
type=semver,enable=true,priority=900,prefix=,suffix=,pattern=,value=,match=
|
||||||
```
|
```
|
||||||
|
|
||||||
### `type=pep440`
|
### `type=pep440`
|
||||||
@@ -540,6 +548,8 @@ tags: |
|
|||||||
type=pep440,pattern={{version}}
|
type=pep440,pattern={{version}}
|
||||||
# use custom value instead of git tag
|
# use custom value instead of git tag
|
||||||
type=pep440,pattern={{version}},value=1.0.0
|
type=pep440,pattern={{version}},value=1.0.0
|
||||||
|
# use custom value and match part of it
|
||||||
|
type=pep440,pattern={{version}},value=p1/v1.0.0,match=v(\d.\d.\d)$
|
||||||
```
|
```
|
||||||
|
|
||||||
Will be used on a [push tag event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push)
|
Will be used on a [push tag event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push)
|
||||||
@@ -555,20 +565,22 @@ with the following expressions:
|
|||||||
* `minor` ; minor version identifier
|
* `minor` ; minor version identifier
|
||||||
* `patch` ; patch version identifier
|
* `patch` ; patch version identifier
|
||||||
|
|
||||||
| Git tag | Pattern | Output |
|
| Git tag | Pattern | Match | Output |
|
||||||
|--------------------|----------------------------------------------------------|----------------------|
|
|--------------|-----------------------|----------------|----------------|
|
||||||
| `1.2.3` | `{{raw}}` | `1.2.3` |
|
| `1.2.3` | `{{raw}}` | | `1.2.3` |
|
||||||
| `1.2.3` | `{{version}}` | `1.2.3` |
|
| `1.2.3` | `{{version}}` | | `1.2.3` |
|
||||||
| `v1.2.3` | `{{version}}` | `1.2.3` |
|
| `v1.2.3` | `{{version}}` | | `1.2.3` |
|
||||||
| `1.2.3` | `{{major}}.{{minor}}` | `1.2` |
|
| `1.2.3` | `{{major}}.{{minor}}` | | `1.2` |
|
||||||
| `1.2.3` | `v{{major}}` | `v1` |
|
| `1.2.3` | `v{{major}}` | | `v1` |
|
||||||
| `v1.2.3rc2` | `{{raw}}` | `v1.2.3rc2` |
|
| `v1.2.3rc2` | `{{raw}}` | | `v1.2.3rc2` |
|
||||||
| `1.2.3rc2` | `{{version}}` | `1.2.3rc2` |
|
| `1.2.3rc2` | `{{version}}` | | `1.2.3rc2` |
|
||||||
| `1.2.3rc2` | `{{major}}.{{minor}}` | `1.2.3rc2`* |
|
| `p1/v1.2.3` | `{{version}}` | `v(\d.\d.\d)$` | `1.2.3` |
|
||||||
| `1.2.3post1` | `{{major}}.{{minor}}` | `1.2.3.post1`* |
|
| `1.2.3rc2` | `{{major}}.{{minor}}` | | `1.2.3rc2`* |
|
||||||
| `1.2.3beta2` | `{{major}}.{{minor}}` | `1.2.3b2`* |
|
| `1.2.3post1` | `{{major}}.{{minor}}` | | `1.2.3.post1`* |
|
||||||
| `1.0dev4` | `{{major}}.{{minor}}` | `1.0.dev4`* |
|
| `1.2.3beta2` | `{{major}}.{{minor}}` | | `1.2.3b2`* |
|
||||||
|
| `1.0dev4` | `{{major}}.{{minor}}` | | `1.0.dev4`* |
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
> *dev/pre/post release will only extend `{{version}}` (or `{{raw}}` if
|
> *dev/pre/post release will only extend `{{version}}` (or `{{raw}}` if
|
||||||
> specified) as tag because they are updated frequently, and contain many
|
> specified) as tag because they are updated frequently, and contain many
|
||||||
> breaking changes that are (by the author's design) not yet fit for public
|
> breaking changes that are (by the author's design) not yet fit for public
|
||||||
@@ -858,6 +870,7 @@ workflow run. Will be empty for a branch reference:
|
|||||||
| `push` | `refs/heads/my/branch` | |
|
| `push` | `refs/heads/my/branch` | |
|
||||||
| `push tag`* | `refs/tags/v1.2.3` | `master` |
|
| `push tag`* | `refs/tags/v1.2.3` | `master` |
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
> *`base_ref` is available in the push payload but doesn't always seem to
|
> *`base_ref` is available in the push payload but doesn't always seem to
|
||||||
> return the expected branch when the push tag event occurs. It's also
|
> return the expected branch when the push tag event occurs. It's also
|
||||||
> [not documented in GitHub docs](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push).
|
> [not documented in GitHub docs](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push).
|
||||||
@@ -869,6 +882,11 @@ workflow run. Will be empty for a branch reference:
|
|||||||
Returns `true` if the branch that triggered the workflow run is the default
|
Returns `true` if the branch that triggered the workflow run is the default
|
||||||
one, otherwise `false`.
|
one, otherwise `false`.
|
||||||
|
|
||||||
|
#### `{{is_not_default_branch}}`
|
||||||
|
|
||||||
|
Returns `true` if the branch that triggered the workflow run is not the default
|
||||||
|
one, otherwise `false`.
|
||||||
|
|
||||||
#### `{{date '<format>' tz='<timezone>'}}`
|
#### `{{date '<format>' tz='<timezone>'}}`
|
||||||
|
|
||||||
Returns the current date rendered by its [moment format](https://momentjs.com/docs/#/displaying/format/).
|
Returns the current date rendered by its [moment format](https://momentjs.com/docs/#/displaying/format/).
|
||||||
|
|||||||
@@ -1,223 +0,0 @@
|
|||||||
import {jest} from '@jest/globals';
|
|
||||||
|
|
||||||
export const context = {
|
|
||||||
repo: {
|
|
||||||
owner: 'docker',
|
|
||||||
repo: 'actions-toolkit'
|
|
||||||
},
|
|
||||||
ref: 'refs/heads/master',
|
|
||||||
runId: 123,
|
|
||||||
payload: {
|
|
||||||
after: '860c1904a1ce19322e91ac35af1ab07466440c37',
|
|
||||||
base_ref: null,
|
|
||||||
before: '5f3331d7f7044c18ca9f12c77d961c4d7cf3276a',
|
|
||||||
commits: [
|
|
||||||
{
|
|
||||||
author: {
|
|
||||||
email: 'crazy-max@users.noreply.github.com',
|
|
||||||
name: 'CrazyMax',
|
|
||||||
username: 'crazy-max'
|
|
||||||
},
|
|
||||||
committer: {
|
|
||||||
email: 'crazy-max@users.noreply.github.com',
|
|
||||||
name: 'CrazyMax',
|
|
||||||
username: 'crazy-max'
|
|
||||||
},
|
|
||||||
distinct: true,
|
|
||||||
id: '860c1904a1ce19322e91ac35af1ab07466440c37',
|
|
||||||
message: 'hello dev',
|
|
||||||
timestamp: '2022-04-19T11:27:24+02:00',
|
|
||||||
tree_id: 'd2c60af597e863787d2d27f569e30495b0b92820',
|
|
||||||
url: 'https://github.com/docker/test-docker-action/commit/860c1904a1ce19322e91ac35af1ab07466440c37'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
compare: 'https://github.com/docker/test-docker-action/compare/5f3331d7f704...860c1904a1ce',
|
|
||||||
created: false,
|
|
||||||
deleted: false,
|
|
||||||
forced: false,
|
|
||||||
head_commit: {
|
|
||||||
author: {
|
|
||||||
email: 'crazy-max@users.noreply.github.com',
|
|
||||||
name: 'CrazyMax',
|
|
||||||
username: 'crazy-max'
|
|
||||||
},
|
|
||||||
committer: {
|
|
||||||
email: 'crazy-max@users.noreply.github.com',
|
|
||||||
name: 'CrazyMax',
|
|
||||||
username: 'crazy-max'
|
|
||||||
},
|
|
||||||
distinct: true,
|
|
||||||
id: '860c1904a1ce19322e91ac35af1ab07466440c37',
|
|
||||||
message: 'hello dev',
|
|
||||||
timestamp: '2022-04-19T11:27:24+02:00',
|
|
||||||
tree_id: 'd2c60af597e863787d2d27f569e30495b0b92820',
|
|
||||||
url: 'https://github.com/docker/test-docker-action/commit/860c1904a1ce19322e91ac35af1ab07466440c37'
|
|
||||||
},
|
|
||||||
organization: {
|
|
||||||
avatar_url: 'https://avatars.githubusercontent.com/u/5429470?v=4',
|
|
||||||
description: 'Docker helps developers bring their ideas to life by conquering the complexity of app development.',
|
|
||||||
events_url: 'https://api.github.com/orgs/docker/events',
|
|
||||||
hooks_url: 'https://api.github.com/orgs/docker/hooks',
|
|
||||||
id: 5429470,
|
|
||||||
issues_url: 'https://api.github.com/orgs/docker/issues',
|
|
||||||
login: 'docker',
|
|
||||||
members_url: 'https://api.github.com/orgs/docker/members{/member}',
|
|
||||||
node_id: 'MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=',
|
|
||||||
public_members_url: 'https://api.github.com/orgs/docker/public_members{/member}',
|
|
||||||
repos_url: 'https://api.github.com/orgs/docker/repos',
|
|
||||||
url: 'https://api.github.com/orgs/docker'
|
|
||||||
},
|
|
||||||
pusher: {
|
|
||||||
email: 'github@crazymax.dev',
|
|
||||||
name: 'crazy-max'
|
|
||||||
},
|
|
||||||
ref: 'refs/heads/dev',
|
|
||||||
repository: {
|
|
||||||
allow_forking: true,
|
|
||||||
archive_url: 'https://api.github.com/repos/docker/test-docker-action/{archive_format}{/ref}',
|
|
||||||
archived: false,
|
|
||||||
assignees_url: 'https://api.github.com/repos/docker/test-docker-action/assignees{/user}',
|
|
||||||
blobs_url: 'https://api.github.com/repos/docker/test-docker-action/git/blobs{/sha}',
|
|
||||||
branches_url: 'https://api.github.com/repos/docker/test-docker-action/branches{/branch}',
|
|
||||||
clone_url: 'https://github.com/docker/test-docker-action.git',
|
|
||||||
collaborators_url: 'https://api.github.com/repos/docker/test-docker-action/collaborators{/collaborator}',
|
|
||||||
comments_url: 'https://api.github.com/repos/docker/test-docker-action/comments{/number}',
|
|
||||||
commits_url: 'https://api.github.com/repos/docker/test-docker-action/commits{/sha}',
|
|
||||||
compare_url: 'https://api.github.com/repos/docker/test-docker-action/compare/{base}...{head}',
|
|
||||||
contents_url: 'https://api.github.com/repos/docker/test-docker-action/contents/{+path}',
|
|
||||||
contributors_url: 'https://api.github.com/repos/docker/test-docker-action/contributors',
|
|
||||||
created_at: 1596792180,
|
|
||||||
default_branch: 'master',
|
|
||||||
deployments_url: 'https://api.github.com/repos/docker/test-docker-action/deployments',
|
|
||||||
description: 'Test "Docker" Actions',
|
|
||||||
disabled: false,
|
|
||||||
downloads_url: 'https://api.github.com/repos/docker/test-docker-action/downloads',
|
|
||||||
events_url: 'https://api.github.com/repos/docker/test-docker-action/events',
|
|
||||||
fork: false,
|
|
||||||
forks: 1,
|
|
||||||
forks_count: 1,
|
|
||||||
forks_url: 'https://api.github.com/repos/docker/test-docker-action/forks',
|
|
||||||
full_name: 'docker/test-docker-action',
|
|
||||||
git_commits_url: 'https://api.github.com/repos/docker/test-docker-action/git/commits{/sha}',
|
|
||||||
git_refs_url: 'https://api.github.com/repos/docker/test-docker-action/git/refs{/sha}',
|
|
||||||
git_tags_url: 'https://api.github.com/repos/docker/test-docker-action/git/tags{/sha}',
|
|
||||||
git_url: 'git://github.com/docker/test-docker-action.git',
|
|
||||||
has_downloads: true,
|
|
||||||
has_issues: true,
|
|
||||||
has_pages: false,
|
|
||||||
has_projects: true,
|
|
||||||
has_wiki: true,
|
|
||||||
homepage: '',
|
|
||||||
hooks_url: 'https://api.github.com/repos/docker/test-docker-action/hooks',
|
|
||||||
html_url: 'https://github.com/docker/test-docker-action',
|
|
||||||
id: 285789493,
|
|
||||||
is_template: false,
|
|
||||||
issue_comment_url: 'https://api.github.com/repos/docker/test-docker-action/issues/comments{/number}',
|
|
||||||
issue_events_url: 'https://api.github.com/repos/docker/test-docker-action/issues/events{/number}',
|
|
||||||
issues_url: 'https://api.github.com/repos/docker/test-docker-action/issues{/number}',
|
|
||||||
keys_url: 'https://api.github.com/repos/docker/test-docker-action/keys{/key_id}',
|
|
||||||
labels_url: 'https://api.github.com/repos/docker/test-docker-action/labels{/name}',
|
|
||||||
language: 'JavaScript',
|
|
||||||
languages_url: 'https://api.github.com/repos/docker/test-docker-action/languages',
|
|
||||||
license: {
|
|
||||||
key: 'mit',
|
|
||||||
name: 'MIT License',
|
|
||||||
node_id: 'MDc6TGljZW5zZTEz',
|
|
||||||
spdx_id: 'MIT',
|
|
||||||
url: 'https://api.github.com/licenses/mit'
|
|
||||||
},
|
|
||||||
master_branch: 'master',
|
|
||||||
merges_url: 'https://api.github.com/repos/docker/test-docker-action/merges',
|
|
||||||
milestones_url: 'https://api.github.com/repos/docker/test-docker-action/milestones{/number}',
|
|
||||||
mirror_url: null,
|
|
||||||
name: 'test-docker-action',
|
|
||||||
node_id: 'MDEwOlJlcG9zaXRvcnkyODU3ODk0OTM=',
|
|
||||||
notifications_url: 'https://api.github.com/repos/docker/test-docker-action/notifications{?since,all,participating}',
|
|
||||||
open_issues: 6,
|
|
||||||
open_issues_count: 6,
|
|
||||||
organization: 'docker',
|
|
||||||
owner: {
|
|
||||||
avatar_url: 'https://avatars.githubusercontent.com/u/5429470?v=4',
|
|
||||||
email: 'info@docker.com',
|
|
||||||
events_url: 'https://api.github.com/users/docker/events{/privacy}',
|
|
||||||
followers_url: 'https://api.github.com/users/docker/followers',
|
|
||||||
following_url: 'https://api.github.com/users/docker/following{/other_user}',
|
|
||||||
gists_url: 'https://api.github.com/users/docker/gists{/gist_id}',
|
|
||||||
gravatar_id: '',
|
|
||||||
html_url: 'https://github.com/docker',
|
|
||||||
id: 5429470,
|
|
||||||
login: 'docker',
|
|
||||||
name: 'docker',
|
|
||||||
node_id: 'MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=',
|
|
||||||
organizations_url: 'https://api.github.com/users/docker/orgs',
|
|
||||||
received_events_url: 'https://api.github.com/users/docker/received_events',
|
|
||||||
repos_url: 'https://api.github.com/users/docker/repos',
|
|
||||||
site_admin: false,
|
|
||||||
starred_url: 'https://api.github.com/users/docker/starred{/owner}{/repo}',
|
|
||||||
subscriptions_url: 'https://api.github.com/users/docker/subscriptions',
|
|
||||||
type: 'Organization',
|
|
||||||
url: 'https://api.github.com/users/docker'
|
|
||||||
},
|
|
||||||
private: true,
|
|
||||||
pulls_url: 'https://api.github.com/repos/docker/test-docker-action/pulls{/number}',
|
|
||||||
pushed_at: 1650360446,
|
|
||||||
releases_url: 'https://api.github.com/repos/docker/test-docker-action/releases{/id}',
|
|
||||||
size: 796,
|
|
||||||
ssh_url: 'git@github.com:docker/test-docker-action.git',
|
|
||||||
stargazers: 0,
|
|
||||||
stargazers_count: 0,
|
|
||||||
stargazers_url: 'https://api.github.com/repos/docker/test-docker-action/stargazers',
|
|
||||||
statuses_url: 'https://api.github.com/repos/docker/test-docker-action/statuses/{sha}',
|
|
||||||
subscribers_url: 'https://api.github.com/repos/docker/test-docker-action/subscribers',
|
|
||||||
subscription_url: 'https://api.github.com/repos/docker/test-docker-action/subscription',
|
|
||||||
svn_url: 'https://github.com/docker/test-docker-action',
|
|
||||||
tags_url: 'https://api.github.com/repos/docker/test-docker-action/tags',
|
|
||||||
teams_url: 'https://api.github.com/repos/docker/test-docker-action/teams',
|
|
||||||
topics: [],
|
|
||||||
trees_url: 'https://api.github.com/repos/docker/test-docker-action/git/trees{/sha}',
|
|
||||||
updated_at: '2022-04-19T09:05:09Z',
|
|
||||||
url: 'https://github.com/docker/test-docker-action',
|
|
||||||
visibility: 'private',
|
|
||||||
watchers: 0,
|
|
||||||
watchers_count: 0
|
|
||||||
},
|
|
||||||
sender: {
|
|
||||||
avatar_url: 'https://avatars.githubusercontent.com/u/1951866?v=4',
|
|
||||||
events_url: 'https://api.github.com/users/crazy-max/events{/privacy}',
|
|
||||||
followers_url: 'https://api.github.com/users/crazy-max/followers',
|
|
||||||
following_url: 'https://api.github.com/users/crazy-max/following{/other_user}',
|
|
||||||
gists_url: 'https://api.github.com/users/crazy-max/gists{/gist_id}',
|
|
||||||
gravatar_id: '',
|
|
||||||
html_url: 'https://github.com/crazy-max',
|
|
||||||
id: 1951866,
|
|
||||||
login: 'crazy-max',
|
|
||||||
node_id: 'MDQ6VXNlcjE5NTE4NjY=',
|
|
||||||
organizations_url: 'https://api.github.com/users/crazy-max/orgs',
|
|
||||||
received_events_url: 'https://api.github.com/users/crazy-max/received_events',
|
|
||||||
repos_url: 'https://api.github.com/users/crazy-max/repos',
|
|
||||||
site_admin: false,
|
|
||||||
starred_url: 'https://api.github.com/users/crazy-max/starred{/owner}{/repo}',
|
|
||||||
subscriptions_url: 'https://api.github.com/users/crazy-max/subscriptions',
|
|
||||||
type: 'User',
|
|
||||||
url: 'https://api.github.com/users/crazy-max'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getOctokit = jest.fn(() => ({
|
|
||||||
rest: {
|
|
||||||
repos: {
|
|
||||||
getCommit: jest.fn(() =>
|
|
||||||
Promise.resolve({
|
|
||||||
data: {
|
|
||||||
commit: {
|
|
||||||
committer: {
|
|
||||||
date: '2024-11-13T13:42:28Z'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
@@ -1,23 +1,12 @@
|
|||||||
import {afterEach, beforeEach, describe, expect, test, it, jest} from '@jest/globals';
|
import {beforeEach, describe, expect, test, it, vi} from 'vitest';
|
||||||
import * as dotenv from 'dotenv';
|
import {Context} from '@actions/github/lib/context.js';
|
||||||
import * as fs from 'fs';
|
import {Git} from '@docker/actions-toolkit/lib/git.js';
|
||||||
import * as path from 'path';
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit.js';
|
||||||
import {Context} from '@actions/github/lib/context';
|
|
||||||
import {Git} from '@docker/actions-toolkit/lib/git';
|
|
||||||
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
|
||||||
|
|
||||||
import {ContextSource, getContext, getInputs, Inputs} from '../src/context';
|
import * as context from '../src/context.js';
|
||||||
|
|
||||||
const toolkit = new Toolkit({githubToken: 'fake-github-token'});
|
const toolkit = new Toolkit({githubToken: 'fake-github-token'});
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
jest.clearAllMocks();
|
|
||||||
jest.spyOn(GitHub, 'context', 'get').mockImplementation((): Context => {
|
|
||||||
return new Context();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getInputs', () => {
|
describe('getInputs', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
process.env = Object.keys(process.env).reduce((object, key) => {
|
process.env = Object.keys(process.env).reduce((object, key) => {
|
||||||
@@ -29,14 +18,14 @@ describe('getInputs', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
test.each([
|
const cases: [number, Map<string, string>, context.Inputs][] = [
|
||||||
[
|
[
|
||||||
0,
|
0,
|
||||||
new Map<string, string>([
|
new Map<string, string>([
|
||||||
['images', 'moby/buildkit\nghcr.io/moby/mbuildkit'],
|
['images', 'moby/buildkit\nghcr.io/moby/mbuildkit'],
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
context: ContextSource.workflow,
|
context: context.ContextSource.workflow,
|
||||||
bakeTarget: 'docker-metadata-action',
|
bakeTarget: 'docker-metadata-action',
|
||||||
flavor: [],
|
flavor: [],
|
||||||
githubToken: '',
|
githubToken: '',
|
||||||
@@ -47,7 +36,7 @@ describe('getInputs', () => {
|
|||||||
sepTags: '\n',
|
sepTags: '\n',
|
||||||
sepAnnotations: '\n',
|
sepAnnotations: '\n',
|
||||||
tags: [],
|
tags: [],
|
||||||
} as Inputs
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
1,
|
1,
|
||||||
@@ -59,7 +48,7 @@ describe('getInputs', () => {
|
|||||||
['sep-annotations', ',']
|
['sep-annotations', ',']
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
context: ContextSource.workflow,
|
context: context.ContextSource.workflow,
|
||||||
bakeTarget: 'metadata',
|
bakeTarget: 'metadata',
|
||||||
flavor: [],
|
flavor: [],
|
||||||
githubToken: '',
|
githubToken: '',
|
||||||
@@ -70,7 +59,7 @@ describe('getInputs', () => {
|
|||||||
sepTags: ',',
|
sepTags: ',',
|
||||||
sepAnnotations: ',',
|
sepAnnotations: ',',
|
||||||
tags: [],
|
tags: [],
|
||||||
} as Inputs
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
2,
|
2,
|
||||||
@@ -78,7 +67,7 @@ describe('getInputs', () => {
|
|||||||
['images', 'moby/buildkit\n#comment\nghcr.io/moby/mbuildkit'],
|
['images', 'moby/buildkit\n#comment\nghcr.io/moby/mbuildkit'],
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
context: ContextSource.workflow,
|
context: context.ContextSource.workflow,
|
||||||
bakeTarget: 'docker-metadata-action',
|
bakeTarget: 'docker-metadata-action',
|
||||||
flavor: [],
|
flavor: [],
|
||||||
githubToken: '',
|
githubToken: '',
|
||||||
@@ -89,53 +78,39 @@ describe('getInputs', () => {
|
|||||||
sepTags: '\n',
|
sepTags: '\n',
|
||||||
sepAnnotations: '\n',
|
sepAnnotations: '\n',
|
||||||
tags: [],
|
tags: [],
|
||||||
} as Inputs
|
}
|
||||||
],
|
],
|
||||||
])(
|
];
|
||||||
'[%d] given %p as inputs, returns %p',
|
test.each(cases)('[%d] given %o as inputs, returns %o', async (num: number, inputs: Map<string, string>, expected: context.Inputs) => {
|
||||||
async (num: number, inputs: Map<string, string>, expected: Inputs) => {
|
inputs.forEach((value: string, name: string) => {
|
||||||
inputs.forEach((value: string, name: string) => {
|
setInput(name, value);
|
||||||
setInput(name, value);
|
});
|
||||||
});
|
const res = await context.getInputs();
|
||||||
expect(await getInputs()).toEqual(expected);
|
expect(res).toEqual(expected);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getContext', () => {
|
describe('getContext', () => {
|
||||||
const originalEnv = process.env;
|
|
||||||
beforeEach(() => {
|
|
||||||
jest.resetModules();
|
|
||||||
process.env = {
|
|
||||||
...originalEnv,
|
|
||||||
...dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures/event_create_branch.env')))
|
|
||||||
};
|
|
||||||
});
|
|
||||||
afterEach(() => {
|
|
||||||
process.env = originalEnv;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('workflow', async () => {
|
it('workflow', async () => {
|
||||||
const context = await getContext(ContextSource.workflow, toolkit);
|
const ctx = await context.getContext(context.ContextSource.workflow, toolkit);
|
||||||
expect(context.ref).toEqual('refs/heads/dev');
|
expect(ctx.ref).toEqual('refs/heads/dev');
|
||||||
expect(context.sha).toEqual('5f3331d7f7044c18ca9f12c77d961c4d7cf3276a');
|
expect(ctx.sha).toEqual('5f3331d7f7044c18ca9f12c77d961c4d7cf3276a');
|
||||||
expect(context.commitDate).toEqual(new Date('2024-11-13T13:42:28.000Z'));
|
expect(ctx.commitDate).toEqual(new Date('2024-11-13T13:42:28.000Z'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('git', async () => {
|
it('git', async () => {
|
||||||
jest.spyOn(Git, 'context').mockImplementation((): Promise<Context> => {
|
vi.spyOn(Git, 'context').mockImplementation((): Promise<Context> => {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
ref: 'refs/heads/git-test',
|
ref: 'refs/heads/git-test',
|
||||||
sha: 'git-test-sha'
|
sha: 'git-test-sha'
|
||||||
} as Context);
|
} as Context);
|
||||||
});
|
});
|
||||||
jest.spyOn(Git, 'commitDate').mockImplementation(async (): Promise<Date> => {
|
vi.spyOn(Git, 'commitDate').mockImplementation(async (): Promise<Date> => {
|
||||||
return new Date('2023-01-01T13:42:28.000Z');
|
return new Date('2023-01-01T13:42:28.000Z');
|
||||||
});
|
});
|
||||||
const context = await getContext(ContextSource.git, toolkit);
|
const ctx = await context.getContext(context.ContextSource.git, toolkit);
|
||||||
expect(context.ref).toEqual('refs/heads/git-test');
|
expect(ctx.ref).toEqual('refs/heads/git-test');
|
||||||
expect(context.sha).toEqual('git-test-sha');
|
expect(ctx.sha).toEqual('git-test-sha');
|
||||||
expect(context.commitDate).toEqual(new Date('2023-01-01T13:42:28.000Z'));
|
expect(ctx.commitDate).toEqual(new Date('2023-01-01T13:42:28.000Z'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {describe, expect, test} from '@jest/globals';
|
import {describe, expect, test} from 'vitest';
|
||||||
|
|
||||||
import {Flavor, Transform} from '../src/flavor';
|
import {Flavor, Transform} from '../src/flavor.js';
|
||||||
|
|
||||||
describe('transform', () => {
|
describe('transform', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
@@ -175,7 +175,7 @@ describe('transform', () => {
|
|||||||
if (!invalid) {
|
if (!invalid) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line jest/no-conditional-expect
|
// eslint-disable-next-line vitest/no-conditional-expect
|
||||||
expect(true).toBe(invalid);
|
expect(true).toBe(invalid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {describe, expect, test} from '@jest/globals';
|
import {describe, expect, test} from 'vitest';
|
||||||
|
|
||||||
import {Transform, Image} from '../src/image';
|
import {Transform, Image} from '../src/image.js';
|
||||||
|
|
||||||
describe('transform', () => {
|
describe('transform', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
@@ -95,7 +95,7 @@ describe('transform', () => {
|
|||||||
if (!invalid) {
|
if (!invalid) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line jest/no-conditional-expect
|
// eslint-disable-next-line vitest/no-conditional-expect
|
||||||
expect(true).toBe(invalid);
|
expect(true).toBe(invalid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,39 +1,45 @@
|
|||||||
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
|
import {beforeEach, describe, expect, test, vi} from 'vitest';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as dotenv from 'dotenv';
|
import * as dotenv from 'dotenv';
|
||||||
|
|
||||||
import {Context} from '@actions/github/lib/context';
|
import {Context} from '@actions/github/lib/context.js';
|
||||||
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
import {GitHub} from '@docker/actions-toolkit/lib/github.js';
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit.js';
|
||||||
import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github';
|
import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github.js';
|
||||||
|
|
||||||
import {ContextSource, getContext, getInputs, Inputs} from '../src/context';
|
import {ContextSource, getContext, getInputs, Inputs} from '../src/context.js';
|
||||||
import {Meta, Version} from '../src/meta';
|
import {Meta, Version} from '../src/meta.js';
|
||||||
|
|
||||||
import repoFixture from './fixtures/repo.json';
|
import repoFixture from './fixtures/repo.json' with {type: 'json'};
|
||||||
|
|
||||||
jest.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise<GitHubRepo> => {
|
vi.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise<GitHubRepo> => {
|
||||||
return <Promise<GitHubRepo>>(repoFixture as unknown);
|
return <Promise<GitHubRepo>>(repoFixture as unknown);
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.spyOn(global.Date.prototype, 'toISOString').mockImplementation(() => {
|
vi.spyOn(global.Date.prototype, 'toISOString').mockImplementation(() => {
|
||||||
return '2020-01-10T00:30:00.000Z';
|
return '2020-01-10T00:30:00.000Z';
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.mock('moment-timezone', () => {
|
vi.mock('moment-timezone', async () => {
|
||||||
return () => (jest.requireActual('moment-timezone') as typeof import('moment-timezone'))('2020-01-10T00:30:00.000Z');
|
const actual = await vi.importActual<unknown>('moment-timezone');
|
||||||
|
const actualModule = actual as {default?: (input?: string | Date) => unknown};
|
||||||
|
const momentTimezone = (typeof actual === 'function' ? actual : actualModule.default) as (input?: string | Date) => unknown;
|
||||||
|
return {
|
||||||
|
__esModule: true,
|
||||||
|
default: () => momentTimezone('2020-01-10T00:30:00.000Z')
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
Object.keys(process.env).forEach(function (key) {
|
Object.keys(process.env).forEach(function (key) {
|
||||||
if (key !== 'GITHUB_TOKEN' && key.startsWith('GITHUB_')) {
|
if (key !== 'GITHUB_TOKEN' && key.startsWith('GITHUB_')) {
|
||||||
delete process.env[key];
|
delete process.env[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
jest.spyOn(GitHub, 'context', 'get').mockImplementation((): Context => {
|
vi.spyOn(GitHub, 'context', 'get').mockImplementation((): Context => {
|
||||||
//@ts-expect-error partial info
|
//@ts-expect-error partial info
|
||||||
return {
|
return {
|
||||||
...new Context(),
|
...new Context(),
|
||||||
@@ -53,7 +59,7 @@ describe('isRawStatement', () => {
|
|||||||
['{{ raw }}', true],
|
['{{ raw }}', true],
|
||||||
['{{ raw}}', true],
|
['{{ raw}}', true],
|
||||||
['{{raw}}', true],
|
['{{raw}}', true],
|
||||||
])('given %p pattern', async (pattern: string, expected: boolean) => {
|
])('given %o pattern', async (pattern: string, expected: boolean) => {
|
||||||
expect(Meta.isRawStatement(pattern)).toEqual(expected);
|
expect(Meta.isRawStatement(pattern)).toEqual(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -79,7 +85,7 @@ const tagsLabelsTest = async (name: string, envFile: string, inputs: Inputs, exV
|
|||||||
|
|
||||||
describe('null', () => {
|
describe('null', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
// eslint-disable-next-line vitest/expect-expect
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'null01',
|
'null01',
|
||||||
@@ -133,12 +139,12 @@ describe('null', () => {
|
|||||||
],
|
],
|
||||||
undefined
|
undefined
|
||||||
],
|
],
|
||||||
])('given %p with %p event', tagsLabelsTest);
|
])('given %o with %o event', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('push', () => {
|
describe('push', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
// eslint-disable-next-line vitest/expect-expect
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'push01',
|
'push01',
|
||||||
@@ -821,13 +827,47 @@ describe('push', () => {
|
|||||||
"org.opencontainers.image.version=mytag-master"
|
"org.opencontainers.image.version=mytag-master"
|
||||||
],
|
],
|
||||||
undefined
|
undefined
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'push22',
|
||||||
|
'event_push_dev.env',
|
||||||
|
{
|
||||||
|
images: ['org/app'],
|
||||||
|
tags: [
|
||||||
|
`type=edge,branch=master`,
|
||||||
|
`type=sha,format=long`,
|
||||||
|
`type=raw,value=notdefbranch,enable={{is_not_default_branch}}`
|
||||||
|
],
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'notdefbranch',
|
||||||
|
partial: [
|
||||||
|
'sha-860c1904a1ce19322e91ac35af1ab07466440c37'
|
||||||
|
],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
"org/app:notdefbranch",
|
||||||
|
"org/app:sha-860c1904a1ce19322e91ac35af1ab07466440c37"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.description=This your first repo!",
|
||||||
|
"org.opencontainers.image.licenses=MIT",
|
||||||
|
"org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
|
||||||
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||||
|
"org.opencontainers.image.title=Hello-World",
|
||||||
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||||
|
"org.opencontainers.image.version=notdefbranch"
|
||||||
|
],
|
||||||
|
undefined
|
||||||
]
|
]
|
||||||
])('given %p with %p event', tagsLabelsTest);
|
])('given %o with %o event', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('tag', () => {
|
describe('tag', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
// eslint-disable-next-line vitest/expect-expect
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'tag01',
|
'tag01',
|
||||||
@@ -1937,13 +1977,76 @@ describe('tag', () => {
|
|||||||
"org.opencontainers.image.version=1.1.1"
|
"org.opencontainers.image.version=1.1.1"
|
||||||
],
|
],
|
||||||
undefined
|
undefined
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'tag34',
|
||||||
|
'event_tag_p1-v1.0.0.env',
|
||||||
|
{
|
||||||
|
images: ['org/app'],
|
||||||
|
tags: [
|
||||||
|
`type=semver,pattern={{version}},"match=v(\\d.\\d.\\d)$"`,
|
||||||
|
]
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: '1.0.0',
|
||||||
|
partial: [],
|
||||||
|
latest: true
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:1.0.0',
|
||||||
|
'org/app:latest'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.description=This your first repo!",
|
||||||
|
"org.opencontainers.image.licenses=MIT",
|
||||||
|
"org.opencontainers.image.revision=860c1904a1ce19322e91ac35af1ab07466440c37",
|
||||||
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||||
|
"org.opencontainers.image.title=Hello-World",
|
||||||
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||||
|
"org.opencontainers.image.version=1.0.0"
|
||||||
|
],
|
||||||
|
undefined
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'push35',
|
||||||
|
'event_push_master.env',
|
||||||
|
{
|
||||||
|
images: ['user/app'],
|
||||||
|
tags: [
|
||||||
|
`type=semver,pattern={{version}},value=p1/v1.2.3,"match=v(\\d.\\d.\\d)$"`,
|
||||||
|
`type=pep440,pattern={{version}},value=p1/v1.2.3,"match=v(\\d.\\d.\\d)$"`,
|
||||||
|
`type=edge`
|
||||||
|
],
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: '1.2.3',
|
||||||
|
partial: ['edge'],
|
||||||
|
latest: true
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'user/app:1.2.3',
|
||||||
|
'user/app:edge',
|
||||||
|
'user/app:latest'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.description=This your first repo!",
|
||||||
|
"org.opencontainers.image.licenses=MIT",
|
||||||
|
"org.opencontainers.image.revision=266574110acf203503badf966df2ea24b5d732d7",
|
||||||
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||||
|
"org.opencontainers.image.title=Hello-World",
|
||||||
|
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||||
|
"org.opencontainers.image.version=1.2.3"
|
||||||
|
],
|
||||||
|
undefined
|
||||||
]
|
]
|
||||||
])('given %p with %p event', tagsLabelsTest);
|
])('given %o with %o event', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('latest', () => {
|
describe('latest', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
// eslint-disable-next-line vitest/expect-expect
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'latest01',
|
'latest01',
|
||||||
@@ -2280,12 +2383,12 @@ describe('latest', () => {
|
|||||||
],
|
],
|
||||||
undefined
|
undefined
|
||||||
]
|
]
|
||||||
])('given %p with %p event', tagsLabelsTest);
|
])('given %o with %o event', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('pr', () => {
|
describe('pr', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
// eslint-disable-next-line vitest/expect-expect
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'pr01',
|
'pr01',
|
||||||
@@ -2668,12 +2771,11 @@ describe('pr', () => {
|
|||||||
],
|
],
|
||||||
undefined
|
undefined
|
||||||
],
|
],
|
||||||
])('given %p with %p event', tagsLabelsTest);
|
])('given %o with %o event', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('pr-head-sha', () => {
|
describe('pr-head-sha', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'pr01',
|
'pr01',
|
||||||
@@ -3044,7 +3146,7 @@ describe('pr-head-sha', () => {
|
|||||||
"org.opencontainers.image.version=src-2020-01-10T00-30-00Z",
|
"org.opencontainers.image.version=src-2020-01-10T00-30-00Z",
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
])('given %p with %p event', async (name: string, envFile: string, inputs: Inputs, exVersion: Version, exTags: Array<string>, exLabelsAnnotations: Array<string>) => {
|
])('given %o with %o event', async (name: string, envFile: string, inputs: Inputs, exVersion: Version, exTags: Array<string>, exLabelsAnnotations: Array<string>) => {
|
||||||
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
||||||
process.env.DOCKER_METADATA_PR_HEAD_SHA = 'true';
|
process.env.DOCKER_METADATA_PR_HEAD_SHA = 'true';
|
||||||
|
|
||||||
@@ -3068,7 +3170,7 @@ describe('pr-head-sha', () => {
|
|||||||
|
|
||||||
describe('schedule', () => {
|
describe('schedule', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
// eslint-disable-next-line vitest/expect-expect
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'schedule01',
|
'schedule01',
|
||||||
@@ -3327,12 +3429,12 @@ describe('schedule', () => {
|
|||||||
],
|
],
|
||||||
undefined
|
undefined
|
||||||
],
|
],
|
||||||
])('given %p with %p event', tagsLabelsTest);
|
])('given %o with %o event', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('release', () => {
|
describe('release', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
// eslint-disable-next-line vitest/expect-expect
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'release01',
|
'release01',
|
||||||
@@ -3429,12 +3531,12 @@ describe('release', () => {
|
|||||||
],
|
],
|
||||||
undefined
|
undefined
|
||||||
]
|
]
|
||||||
])('given %s with %p event', tagsLabelsTest);
|
])('given %o with %o event', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('raw', () => {
|
describe('raw', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
// eslint-disable-next-line vitest/expect-expect
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'raw01',
|
'raw01',
|
||||||
@@ -3809,12 +3911,11 @@ describe('raw', () => {
|
|||||||
],
|
],
|
||||||
undefined
|
undefined
|
||||||
],
|
],
|
||||||
])('given %p wth %p event', tagsLabelsTest);
|
])('given %o with %o event', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('json', () => {
|
describe('json', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'json01',
|
'json01',
|
||||||
@@ -3839,6 +3940,12 @@ describe('json', () => {
|
|||||||
"user/app:custom",
|
"user/app:custom",
|
||||||
"user/app:tags"
|
"user/app:tags"
|
||||||
],
|
],
|
||||||
|
"tag-names": [
|
||||||
|
"dev",
|
||||||
|
"my",
|
||||||
|
"custom",
|
||||||
|
"tags"
|
||||||
|
],
|
||||||
"labels": {
|
"labels": {
|
||||||
"foo": "",
|
"foo": "",
|
||||||
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
||||||
@@ -3877,6 +3984,10 @@ describe('json', () => {
|
|||||||
"user/app:dev",
|
"user/app:dev",
|
||||||
"user/app:my",
|
"user/app:my",
|
||||||
],
|
],
|
||||||
|
"tag-names": [
|
||||||
|
"dev",
|
||||||
|
"my",
|
||||||
|
],
|
||||||
"labels": {
|
"labels": {
|
||||||
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
||||||
"org.opencontainers.image.description": "This your first repo!",
|
"org.opencontainers.image.description": "This your first repo!",
|
||||||
@@ -3920,6 +4031,13 @@ describe('json', () => {
|
|||||||
"user/app:tags",
|
"user/app:tags",
|
||||||
"user/app:latest"
|
"user/app:latest"
|
||||||
],
|
],
|
||||||
|
"tag-names": [
|
||||||
|
"release1",
|
||||||
|
"my",
|
||||||
|
"custom",
|
||||||
|
"tags",
|
||||||
|
"latest"
|
||||||
|
],
|
||||||
"labels": {
|
"labels": {
|
||||||
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
||||||
"org.opencontainers.image.description": "This your first repo!",
|
"org.opencontainers.image.description": "This your first repo!",
|
||||||
@@ -3964,6 +4082,12 @@ describe('json', () => {
|
|||||||
"user/app:custom",
|
"user/app:custom",
|
||||||
"user/app:tags"
|
"user/app:tags"
|
||||||
],
|
],
|
||||||
|
"tag-names": [
|
||||||
|
"20200110",
|
||||||
|
"my",
|
||||||
|
"custom",
|
||||||
|
"tags"
|
||||||
|
],
|
||||||
"labels": {
|
"labels": {
|
||||||
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
||||||
"org.opencontainers.image.description": "This your first repo!",
|
"org.opencontainers.image.description": "This your first repo!",
|
||||||
@@ -4017,6 +4141,15 @@ describe('json', () => {
|
|||||||
"ghcr.io/user/app:tags",
|
"ghcr.io/user/app:tags",
|
||||||
"ghcr.io/user/app:latest"
|
"ghcr.io/user/app:latest"
|
||||||
],
|
],
|
||||||
|
"tag-names": [
|
||||||
|
"1.1.1",
|
||||||
|
"1.1",
|
||||||
|
"1",
|
||||||
|
"my",
|
||||||
|
"custom",
|
||||||
|
"tags",
|
||||||
|
"latest",
|
||||||
|
],
|
||||||
"labels": {
|
"labels": {
|
||||||
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
||||||
"org.opencontainers.image.description": "This your first repo!",
|
"org.opencontainers.image.description": "This your first repo!",
|
||||||
@@ -4059,6 +4192,11 @@ describe('json', () => {
|
|||||||
"ghcr.io/user/app:custom",
|
"ghcr.io/user/app:custom",
|
||||||
"ghcr.io/user/app:tags"
|
"ghcr.io/user/app:tags"
|
||||||
],
|
],
|
||||||
|
"tag-names": [
|
||||||
|
"my",
|
||||||
|
"custom",
|
||||||
|
"tags",
|
||||||
|
],
|
||||||
"labels": {
|
"labels": {
|
||||||
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
||||||
"org.opencontainers.image.description": "This your first repo!",
|
"org.opencontainers.image.description": "This your first repo!",
|
||||||
@@ -4099,6 +4237,10 @@ describe('json', () => {
|
|||||||
"org/app:v1.1.1",
|
"org/app:v1.1.1",
|
||||||
"org/app:latest"
|
"org/app:latest"
|
||||||
],
|
],
|
||||||
|
"tag-names": [
|
||||||
|
"v1.1.1",
|
||||||
|
"latest"
|
||||||
|
],
|
||||||
"labels": {
|
"labels": {
|
||||||
"maintainer": "CrazyMax",
|
"maintainer": "CrazyMax",
|
||||||
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
|
||||||
@@ -4123,7 +4265,7 @@ describe('json', () => {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
])('given %p with %p event', async (name: string, envFile: string, inputs: Inputs, exJSON: unknown) => {
|
])('given %o with %o event', async (name: string, envFile: string, inputs: Inputs, exJSON: unknown) => {
|
||||||
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
||||||
|
|
||||||
const toolkit = new Toolkit();
|
const toolkit = new Toolkit();
|
||||||
@@ -4137,7 +4279,6 @@ describe('json', () => {
|
|||||||
|
|
||||||
describe('bakeFile', () => {
|
describe('bakeFile', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'bakeFile01',
|
'bakeFile01',
|
||||||
@@ -4639,7 +4780,7 @@ describe('bakeFile', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
])('given %p with %p event', async (name: string, envFile: string, inputs: Inputs, exBakeTags: unknown, exBakeLabels: unknown, exBakeAnnotations: unknown) => {
|
])('given %o with %o event', async (name: string, envFile: string, inputs: Inputs, exBakeTags: unknown, exBakeLabels: unknown, exBakeAnnotations: unknown) => {
|
||||||
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
||||||
|
|
||||||
const toolkit = new Toolkit();
|
const toolkit = new Toolkit();
|
||||||
@@ -4659,7 +4800,6 @@ describe('bakeFile', () => {
|
|||||||
|
|
||||||
describe('bakeFileTagsLabels', () => {
|
describe('bakeFileTagsLabels', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'bakeFileTagsLabels01',
|
'bakeFileTagsLabels01',
|
||||||
@@ -4703,7 +4843,7 @@ describe('bakeFileTagsLabels', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
])('given %p with %p event', async (name: string, envFile: string, inputs: Inputs, exBakeDefinition: unknown) => {
|
])('given %o with %o event', async (name: string, envFile: string, inputs: Inputs, exBakeDefinition: unknown) => {
|
||||||
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
||||||
|
|
||||||
const toolkit = new Toolkit();
|
const toolkit = new Toolkit();
|
||||||
@@ -4717,7 +4857,6 @@ describe('bakeFileTagsLabels', () => {
|
|||||||
|
|
||||||
describe('sepTags', () => {
|
describe('sepTags', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// eslint-disable-next-line jest/expect-expect
|
|
||||||
test.each([
|
test.each([
|
||||||
[
|
[
|
||||||
'sepTags01',
|
'sepTags01',
|
||||||
@@ -4749,14 +4888,11 @@ describe('sepTags', () => {
|
|||||||
} as Inputs,
|
} as Inputs,
|
||||||
"user/app:dev,user/app:my,user/app:custom,user/app:tags"
|
"user/app:dev,user/app:my,user/app:custom,user/app:tags"
|
||||||
]
|
]
|
||||||
])('given %p with %p event', async (name: string, envFile: string, inputs: Inputs, expTags: string) => {
|
])('given %o with %o event', async (name: string, envFile: string, inputs: Inputs, expTags: string) => {
|
||||||
|
|
||||||
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
process.env = dotenv.parse(fs.readFileSync(path.join(__dirname, 'fixtures', envFile)));
|
||||||
|
|
||||||
const toolkit = new Toolkit();
|
const toolkit = new Toolkit();
|
||||||
|
|
||||||
const repo = await toolkit.github.repoData();
|
const repo = await toolkit.github.repoData();
|
||||||
|
|
||||||
const meta = new Meta({...getInputs(), ...inputs}, await getContext(ContextSource.workflow, toolkit), repo);
|
const meta = new Meta({...getInputs(), ...inputs}, await getContext(ContextSource.workflow, toolkit), repo);
|
||||||
|
|
||||||
expect(meta.getTags().join(inputs.sepTags)).toEqual(expTags);
|
expect(meta.getTags().join(inputs.sepTags)).toEqual(expTags);
|
||||||
|
|||||||
259
__tests__/setup.unit.ts
Normal file
259
__tests__/setup.unit.ts
Normal file
@@ -0,0 +1,259 @@
|
|||||||
|
import fs from 'node:fs';
|
||||||
|
import {createRequire} from 'node:module';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import {vi} from 'vitest';
|
||||||
|
|
||||||
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-metadata-action-'));
|
||||||
|
|
||||||
|
process.env = Object.assign({}, process.env, {
|
||||||
|
TEMP: tmpDir,
|
||||||
|
GITHUB_REPOSITORY: 'docker/metadata-action',
|
||||||
|
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
||||||
|
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
||||||
|
});
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
type RequireCacheEntry = NonNullable<(typeof require.cache)[string]>;
|
||||||
|
|
||||||
|
const githubMock = {
|
||||||
|
context: {
|
||||||
|
repo: {
|
||||||
|
owner: 'docker',
|
||||||
|
repo: 'actions-toolkit'
|
||||||
|
},
|
||||||
|
ref: 'refs/heads/dev',
|
||||||
|
sha: '5f3331d7f7044c18ca9f12c77d961c4d7cf3276a',
|
||||||
|
runId: 2188748038,
|
||||||
|
runNumber: 15,
|
||||||
|
payload: {
|
||||||
|
after: '860c1904a1ce19322e91ac35af1ab07466440c37',
|
||||||
|
base_ref: null,
|
||||||
|
before: '5f3331d7f7044c18ca9f12c77d961c4d7cf3276a',
|
||||||
|
commits: [
|
||||||
|
{
|
||||||
|
author: {
|
||||||
|
email: 'crazy-max@users.noreply.github.com',
|
||||||
|
name: 'CrazyMax',
|
||||||
|
username: 'crazy-max'
|
||||||
|
},
|
||||||
|
committer: {
|
||||||
|
email: 'crazy-max@users.noreply.github.com',
|
||||||
|
name: 'CrazyMax',
|
||||||
|
username: 'crazy-max'
|
||||||
|
},
|
||||||
|
distinct: true,
|
||||||
|
id: '860c1904a1ce19322e91ac35af1ab07466440c37',
|
||||||
|
message: 'hello dev',
|
||||||
|
timestamp: '2022-04-19T11:27:24+02:00',
|
||||||
|
tree_id: 'd2c60af597e863787d2d27f569e30495b0b92820',
|
||||||
|
url: 'https://github.com/docker/test-docker-action/commit/860c1904a1ce19322e91ac35af1ab07466440c37'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
compare: 'https://github.com/docker/test-docker-action/compare/5f3331d7f704...860c1904a1ce',
|
||||||
|
created: false,
|
||||||
|
deleted: false,
|
||||||
|
forced: false,
|
||||||
|
head_commit: {
|
||||||
|
author: {
|
||||||
|
email: 'crazy-max@users.noreply.github.com',
|
||||||
|
name: 'CrazyMax',
|
||||||
|
username: 'crazy-max'
|
||||||
|
},
|
||||||
|
committer: {
|
||||||
|
email: 'crazy-max@users.noreply.github.com',
|
||||||
|
name: 'CrazyMax',
|
||||||
|
username: 'crazy-max'
|
||||||
|
},
|
||||||
|
distinct: true,
|
||||||
|
id: '860c1904a1ce19322e91ac35af1ab07466440c37',
|
||||||
|
message: 'hello dev',
|
||||||
|
timestamp: '2022-04-19T11:27:24+02:00',
|
||||||
|
tree_id: 'd2c60af597e863787d2d27f569e30495b0b92820',
|
||||||
|
url: 'https://github.com/docker/test-docker-action/commit/860c1904a1ce19322e91ac35af1ab07466440c37'
|
||||||
|
},
|
||||||
|
organization: {
|
||||||
|
avatar_url: 'https://avatars.githubusercontent.com/u/5429470?v=4',
|
||||||
|
description: 'Docker helps developers bring their ideas to life by conquering the complexity of app development.',
|
||||||
|
events_url: 'https://api.github.com/orgs/docker/events',
|
||||||
|
hooks_url: 'https://api.github.com/orgs/docker/hooks',
|
||||||
|
id: 5429470,
|
||||||
|
issues_url: 'https://api.github.com/orgs/docker/issues',
|
||||||
|
login: 'docker',
|
||||||
|
members_url: 'https://api.github.com/orgs/docker/members{/member}',
|
||||||
|
node_id: 'MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=',
|
||||||
|
public_members_url: 'https://api.github.com/orgs/docker/public_members{/member}',
|
||||||
|
repos_url: 'https://api.github.com/orgs/docker/repos',
|
||||||
|
url: 'https://api.github.com/orgs/docker'
|
||||||
|
},
|
||||||
|
pusher: {
|
||||||
|
email: 'github@crazymax.dev',
|
||||||
|
name: 'crazy-max'
|
||||||
|
},
|
||||||
|
ref: 'refs/heads/dev',
|
||||||
|
repository: {
|
||||||
|
allow_forking: true,
|
||||||
|
archive_url: 'https://api.github.com/repos/docker/test-docker-action/{archive_format}{/ref}',
|
||||||
|
archived: false,
|
||||||
|
assignees_url: 'https://api.github.com/repos/docker/test-docker-action/assignees{/user}',
|
||||||
|
blobs_url: 'https://api.github.com/repos/docker/test-docker-action/git/blobs{/sha}',
|
||||||
|
branches_url: 'https://api.github.com/repos/docker/test-docker-action/branches{/branch}',
|
||||||
|
clone_url: 'https://github.com/docker/test-docker-action.git',
|
||||||
|
collaborators_url: 'https://api.github.com/repos/docker/test-docker-action/collaborators{/collaborator}',
|
||||||
|
comments_url: 'https://api.github.com/repos/docker/test-docker-action/comments{/number}',
|
||||||
|
commits_url: 'https://api.github.com/repos/docker/test-docker-action/commits{/sha}',
|
||||||
|
compare_url: 'https://api.github.com/repos/docker/test-docker-action/compare/{base}...{head}',
|
||||||
|
contents_url: 'https://api.github.com/repos/docker/test-docker-action/contents/{+path}',
|
||||||
|
contributors_url: 'https://api.github.com/repos/docker/test-docker-action/contributors',
|
||||||
|
created_at: 1596792180,
|
||||||
|
default_branch: 'master',
|
||||||
|
deployments_url: 'https://api.github.com/repos/docker/test-docker-action/deployments',
|
||||||
|
description: 'Test "Docker" Actions',
|
||||||
|
disabled: false,
|
||||||
|
downloads_url: 'https://api.github.com/repos/docker/test-docker-action/downloads',
|
||||||
|
events_url: 'https://api.github.com/repos/docker/test-docker-action/events',
|
||||||
|
fork: false,
|
||||||
|
forks: 1,
|
||||||
|
forks_count: 1,
|
||||||
|
forks_url: 'https://api.github.com/repos/docker/test-docker-action/forks',
|
||||||
|
full_name: 'docker/test-docker-action',
|
||||||
|
git_commits_url: 'https://api.github.com/repos/docker/test-docker-action/git/commits{/sha}',
|
||||||
|
git_refs_url: 'https://api.github.com/repos/docker/test-docker-action/git/refs{/sha}',
|
||||||
|
git_tags_url: 'https://api.github.com/repos/docker/test-docker-action/git/tags{/sha}',
|
||||||
|
git_url: 'git://github.com/docker/test-docker-action.git',
|
||||||
|
has_downloads: true,
|
||||||
|
has_issues: true,
|
||||||
|
has_pages: false,
|
||||||
|
has_projects: true,
|
||||||
|
has_wiki: true,
|
||||||
|
homepage: '',
|
||||||
|
hooks_url: 'https://api.github.com/repos/docker/test-docker-action/hooks',
|
||||||
|
html_url: 'https://github.com/docker/test-docker-action',
|
||||||
|
id: 285789493,
|
||||||
|
is_template: false,
|
||||||
|
issue_comment_url: 'https://api.github.com/repos/docker/test-docker-action/issues/comments{/number}',
|
||||||
|
issue_events_url: 'https://api.github.com/repos/docker/test-docker-action/issues/events{/number}',
|
||||||
|
issues_url: 'https://api.github.com/repos/docker/test-docker-action/issues{/number}',
|
||||||
|
keys_url: 'https://api.github.com/repos/docker/test-docker-action/keys{/key_id}',
|
||||||
|
labels_url: 'https://api.github.com/repos/docker/test-docker-action/labels{/name}',
|
||||||
|
language: 'JavaScript',
|
||||||
|
languages_url: 'https://api.github.com/repos/docker/test-docker-action/languages',
|
||||||
|
license: {
|
||||||
|
key: 'mit',
|
||||||
|
name: 'MIT License',
|
||||||
|
node_id: 'MDc6TGljZW5zZTEz',
|
||||||
|
spdx_id: 'MIT',
|
||||||
|
url: 'https://api.github.com/licenses/mit'
|
||||||
|
},
|
||||||
|
master_branch: 'master',
|
||||||
|
merges_url: 'https://api.github.com/repos/docker/test-docker-action/merges',
|
||||||
|
milestones_url: 'https://api.github.com/repos/docker/test-docker-action/milestones{/number}',
|
||||||
|
mirror_url: null,
|
||||||
|
name: 'test-docker-action',
|
||||||
|
node_id: 'MDEwOlJlcG9zaXRvcnkyODU3ODk0OTM=',
|
||||||
|
notifications_url: 'https://api.github.com/repos/docker/test-docker-action/notifications{?since,all,participating}',
|
||||||
|
open_issues: 6,
|
||||||
|
open_issues_count: 6,
|
||||||
|
organization: 'docker',
|
||||||
|
owner: {
|
||||||
|
avatar_url: 'https://avatars.githubusercontent.com/u/5429470?v=4',
|
||||||
|
email: 'info@docker.com',
|
||||||
|
events_url: 'https://api.github.com/users/docker/events{/privacy}',
|
||||||
|
followers_url: 'https://api.github.com/users/docker/followers',
|
||||||
|
following_url: 'https://api.github.com/users/docker/following{/other_user}',
|
||||||
|
gists_url: 'https://api.github.com/users/docker/gists{/gist_id}',
|
||||||
|
gravatar_id: '',
|
||||||
|
html_url: 'https://github.com/docker',
|
||||||
|
id: 5429470,
|
||||||
|
login: 'docker',
|
||||||
|
name: 'docker',
|
||||||
|
node_id: 'MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=',
|
||||||
|
organizations_url: 'https://api.github.com/users/docker/orgs',
|
||||||
|
received_events_url: 'https://api.github.com/users/docker/received_events',
|
||||||
|
repos_url: 'https://api.github.com/users/docker/repos',
|
||||||
|
site_admin: false,
|
||||||
|
starred_url: 'https://api.github.com/users/docker/starred{/owner}{/repo}',
|
||||||
|
subscriptions_url: 'https://api.github.com/users/docker/subscriptions',
|
||||||
|
type: 'Organization',
|
||||||
|
url: 'https://api.github.com/users/docker'
|
||||||
|
},
|
||||||
|
private: true,
|
||||||
|
pulls_url: 'https://api.github.com/repos/docker/test-docker-action/pulls{/number}',
|
||||||
|
pushed_at: 1650360446,
|
||||||
|
releases_url: 'https://api.github.com/repos/docker/test-docker-action/releases{/id}',
|
||||||
|
size: 796,
|
||||||
|
ssh_url: 'git@github.com:docker/test-docker-action.git',
|
||||||
|
stargazers: 0,
|
||||||
|
stargazers_count: 0,
|
||||||
|
stargazers_url: 'https://api.github.com/repos/docker/test-docker-action/stargazers',
|
||||||
|
statuses_url: 'https://api.github.com/repos/docker/test-docker-action/statuses/{sha}',
|
||||||
|
subscribers_url: 'https://api.github.com/repos/docker/test-docker-action/subscribers',
|
||||||
|
subscription_url: 'https://api.github.com/repos/docker/test-docker-action/subscription',
|
||||||
|
svn_url: 'https://github.com/docker/test-docker-action',
|
||||||
|
tags_url: 'https://api.github.com/repos/docker/test-docker-action/tags',
|
||||||
|
teams_url: 'https://api.github.com/repos/docker/test-docker-action/teams',
|
||||||
|
topics: [],
|
||||||
|
trees_url: 'https://api.github.com/repos/docker/test-docker-action/git/trees{/sha}',
|
||||||
|
updated_at: '2022-04-19T09:05:09Z',
|
||||||
|
url: 'https://github.com/docker/test-docker-action',
|
||||||
|
visibility: 'private',
|
||||||
|
watchers: 0,
|
||||||
|
watchers_count: 0
|
||||||
|
},
|
||||||
|
sender: {
|
||||||
|
avatar_url: 'https://avatars.githubusercontent.com/u/1951866?v=4',
|
||||||
|
events_url: 'https://api.github.com/users/crazy-max/events{/privacy}',
|
||||||
|
followers_url: 'https://api.github.com/users/crazy-max/followers',
|
||||||
|
following_url: 'https://api.github.com/users/crazy-max/following{/other_user}',
|
||||||
|
gists_url: 'https://api.github.com/users/crazy-max/gists{/gist_id}',
|
||||||
|
gravatar_id: '',
|
||||||
|
html_url: 'https://github.com/crazy-max',
|
||||||
|
id: 1951866,
|
||||||
|
login: 'crazy-max',
|
||||||
|
node_id: 'MDQ6VXNlcjE5NTE4NjY=',
|
||||||
|
organizations_url: 'https://api.github.com/users/crazy-max/orgs',
|
||||||
|
received_events_url: 'https://api.github.com/users/crazy-max/received_events',
|
||||||
|
repos_url: 'https://api.github.com/users/crazy-max/repos',
|
||||||
|
site_admin: false,
|
||||||
|
starred_url: 'https://api.github.com/users/crazy-max/starred{/owner}{/repo}',
|
||||||
|
subscriptions_url: 'https://api.github.com/users/crazy-max/subscriptions',
|
||||||
|
type: 'User',
|
||||||
|
url: 'https://api.github.com/users/crazy-max'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getOctokit: () => ({
|
||||||
|
rest: {
|
||||||
|
repos: {
|
||||||
|
getCommit: async () => ({
|
||||||
|
data: {
|
||||||
|
commit: {
|
||||||
|
committer: {
|
||||||
|
date: '2024-11-13T13:42:28Z'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
vi.mock('@actions/github', () => githubMock);
|
||||||
|
|
||||||
|
for (const mod of ['@actions/github', '@docker/actions-toolkit/node_modules/@actions/github']) {
|
||||||
|
try {
|
||||||
|
const resolved = require.resolve(mod);
|
||||||
|
vi.doMock(resolved, () => githubMock);
|
||||||
|
require.cache[resolved] = {
|
||||||
|
id: resolved,
|
||||||
|
filename: resolved,
|
||||||
|
loaded: true,
|
||||||
|
exports: githubMock,
|
||||||
|
children: [],
|
||||||
|
paths: []
|
||||||
|
} as RequireCacheEntry;
|
||||||
|
} catch {
|
||||||
|
// Ignore unresolved optional paths; vi.mock handles module-level mocking.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import {describe, expect, test} from '@jest/globals';
|
import {describe, expect, test} from 'vitest';
|
||||||
|
|
||||||
import {Transform, Parse, Tag, Type, RefEvent, ShaFormat, DefaultPriorities} from '../src/tag';
|
import {Transform, Parse, Tag, Type, RefEvent, ShaFormat, DefaultPriorities} from '../src/tag.js';
|
||||||
|
|
||||||
describe('transform', () => {
|
describe('transform', () => {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
@@ -32,7 +32,8 @@ describe('transform', () => {
|
|||||||
"priority": DefaultPriorities[Type.Semver],
|
"priority": DefaultPriorities[Type.Semver],
|
||||||
"enable": "true",
|
"enable": "true",
|
||||||
"pattern": "{{version}}",
|
"pattern": "{{version}}",
|
||||||
"value": ""
|
"value": "",
|
||||||
|
"match": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -106,7 +107,7 @@ describe('transform', () => {
|
|||||||
if (!invalid) {
|
if (!invalid) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line jest/no-conditional-expect
|
// eslint-disable-next-line vitest/no-conditional-expect
|
||||||
expect(true).toBe(invalid);
|
expect(true).toBe(invalid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -147,7 +148,8 @@ describe('parse', () => {
|
|||||||
"priority": DefaultPriorities[Type.Semver],
|
"priority": DefaultPriorities[Type.Semver],
|
||||||
"enable": "true",
|
"enable": "true",
|
||||||
"pattern": "{{version}}",
|
"pattern": "{{version}}",
|
||||||
"value": ""
|
"value": "",
|
||||||
|
"match": ""
|
||||||
}
|
}
|
||||||
} as Tag,
|
} as Tag,
|
||||||
false
|
false
|
||||||
@@ -160,7 +162,8 @@ describe('parse', () => {
|
|||||||
"priority": "1",
|
"priority": "1",
|
||||||
"enable": "true",
|
"enable": "true",
|
||||||
"pattern": "{{version}}",
|
"pattern": "{{version}}",
|
||||||
"value": ""
|
"value": "",
|
||||||
|
"match": ""
|
||||||
}
|
}
|
||||||
} as Tag,
|
} as Tag,
|
||||||
false
|
false
|
||||||
@@ -173,7 +176,22 @@ describe('parse', () => {
|
|||||||
"priority": "1",
|
"priority": "1",
|
||||||
"enable": "true",
|
"enable": "true",
|
||||||
"pattern": "{{version}}",
|
"pattern": "{{version}}",
|
||||||
"value": "v1.0.0"
|
"value": "v1.0.0",
|
||||||
|
"match": ""
|
||||||
|
}
|
||||||
|
} as Tag,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
`type=semver,priority=1,enable=true,pattern={{version}},value=p1/v1.0.0,"match=v(\\d.\\d.\\d)$"`,
|
||||||
|
{
|
||||||
|
type: Type.Semver,
|
||||||
|
attrs: {
|
||||||
|
"priority": "1",
|
||||||
|
"enable": "true",
|
||||||
|
"pattern": "{{version}}",
|
||||||
|
"value": "p1/v1.0.0",
|
||||||
|
"match": "v(\\d.\\d.\\d)$"
|
||||||
}
|
}
|
||||||
} as Tag,
|
} as Tag,
|
||||||
false
|
false
|
||||||
@@ -443,7 +461,7 @@ describe('parse', () => {
|
|||||||
if (!invalid) {
|
if (!invalid) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line jest/no-conditional-expect
|
// eslint-disable-next-line vitest/no-conditional-expect
|
||||||
expect(true).toBe(invalid);
|
expect(true).toBe(invalid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ outputs:
|
|||||||
description: 'Generated Docker image version'
|
description: 'Generated Docker image version'
|
||||||
tags:
|
tags:
|
||||||
description: 'Generated Docker tags'
|
description: 'Generated Docker tags'
|
||||||
|
tag-names:
|
||||||
|
description: 'Generated Docker tag names without image base name'
|
||||||
labels:
|
labels:
|
||||||
description: 'Generated Docker labels'
|
description: 'Generated Docker labels'
|
||||||
annotations:
|
annotations:
|
||||||
|
|||||||
@@ -3,10 +3,11 @@
|
|||||||
ARG NODE_VERSION=20
|
ARG NODE_VERSION=20
|
||||||
|
|
||||||
FROM node:${NODE_VERSION}-alpine AS base
|
FROM node:${NODE_VERSION}-alpine AS base
|
||||||
RUN apk add --no-cache cpio findutils git
|
RUN apk add --no-cache cpio findutils git rsync
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/src/.yarn/cache <<EOT
|
--mount=type=cache,target=/src/.yarn/cache <<EOT
|
||||||
|
set -e
|
||||||
corepack enable
|
corepack enable
|
||||||
yarn --version
|
yarn --version
|
||||||
yarn config set --home enableTelemetry 0
|
yarn config set --home enableTelemetry 0
|
||||||
@@ -34,18 +35,27 @@ RUN --mount=type=bind,target=.,rw <<EOT
|
|||||||
EOT
|
EOT
|
||||||
|
|
||||||
FROM deps AS build
|
FROM deps AS build
|
||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=target=/context \
|
||||||
--mount=type=cache,target=/src/.yarn/cache \
|
--mount=type=cache,target=/src/.yarn/cache \
|
||||||
--mount=type=cache,target=/src/node_modules \
|
--mount=type=cache,target=/src/node_modules <<EOT
|
||||||
yarn run build && mkdir /out && cp -Rf dist /out/
|
set -e
|
||||||
|
rsync -a /context/. .
|
||||||
|
rm -rf dist
|
||||||
|
yarn run build
|
||||||
|
mkdir /out
|
||||||
|
cp -r dist /out
|
||||||
|
EOT
|
||||||
|
|
||||||
FROM scratch AS build-update
|
FROM scratch AS build-update
|
||||||
COPY --from=build /out /
|
COPY --from=build /out /
|
||||||
|
|
||||||
FROM build AS build-validate
|
FROM build AS build-validate
|
||||||
RUN --mount=type=bind,target=.,rw <<EOT
|
RUN --mount=target=/context \
|
||||||
|
--mount=target=.,type=tmpfs <<EOT
|
||||||
set -e
|
set -e
|
||||||
|
rsync -a /context/. .
|
||||||
git add -A
|
git add -A
|
||||||
|
rm -rf dist
|
||||||
cp -rf /out/* .
|
cp -rf /out/* .
|
||||||
if [ -n "$(git status --porcelain -- dist)" ]; then
|
if [ -n "$(git status --porcelain -- dist)" ]; then
|
||||||
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
|
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
|
||||||
@@ -58,8 +68,7 @@ FROM deps AS format
|
|||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/src/.yarn/cache \
|
--mount=type=cache,target=/src/.yarn/cache \
|
||||||
--mount=type=cache,target=/src/node_modules \
|
--mount=type=cache,target=/src/node_modules \
|
||||||
yarn run format \
|
yarn run format && mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out
|
||||||
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out
|
|
||||||
|
|
||||||
FROM scratch AS format-update
|
FROM scratch AS format-update
|
||||||
COPY --from=format /out /
|
COPY --from=format /out /
|
||||||
@@ -74,7 +83,7 @@ FROM deps AS test
|
|||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/src/.yarn/cache \
|
--mount=type=cache,target=/src/.yarn/cache \
|
||||||
--mount=type=cache,target=/src/node_modules \
|
--mount=type=cache,target=/src/node_modules \
|
||||||
yarn run test --coverage --coverageDirectory=/tmp/coverage
|
yarn run test --coverage --coverage.reportsDirectory=/tmp/coverage
|
||||||
|
|
||||||
FROM scratch AS test-coverage
|
FROM scratch AS test-coverage
|
||||||
COPY --from=test /tmp/coverage /
|
COPY --from=test /tmp/coverage /
|
||||||
|
|||||||
299
dist/606.index.js
generated
vendored
Normal file
299
dist/606.index.js
generated
vendored
Normal file
@@ -0,0 +1,299 @@
|
|||||||
|
export const id = 606;
|
||||||
|
export const ids = [606];
|
||||||
|
export const modules = {
|
||||||
|
|
||||||
|
/***/ 606:
|
||||||
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||||
|
|
||||||
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
|
/* harmony export */ "default": () => (/* binding */ pMap)
|
||||||
|
/* harmony export */ });
|
||||||
|
/* unused harmony exports pMapIterable, pMapSkip */
|
||||||
|
async function pMap(
|
||||||
|
iterable,
|
||||||
|
mapper,
|
||||||
|
{
|
||||||
|
concurrency = Number.POSITIVE_INFINITY,
|
||||||
|
stopOnError = true,
|
||||||
|
signal,
|
||||||
|
} = {},
|
||||||
|
) {
|
||||||
|
return new Promise((resolve_, reject_) => {
|
||||||
|
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
|
||||||
|
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof mapper !== 'function') {
|
||||||
|
throw new TypeError('Mapper function is required');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!((Number.isSafeInteger(concurrency) && concurrency >= 1) || concurrency === Number.POSITIVE_INFINITY)) {
|
||||||
|
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = [];
|
||||||
|
const errors = [];
|
||||||
|
const skippedIndexesMap = new Map();
|
||||||
|
let isRejected = false;
|
||||||
|
let isResolved = false;
|
||||||
|
let isIterableDone = false;
|
||||||
|
let resolvingCount = 0;
|
||||||
|
let currentIndex = 0;
|
||||||
|
const iterator = iterable[Symbol.iterator] === undefined ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
|
||||||
|
|
||||||
|
const signalListener = () => {
|
||||||
|
reject(signal.reason);
|
||||||
|
};
|
||||||
|
|
||||||
|
const cleanup = () => {
|
||||||
|
signal?.removeEventListener('abort', signalListener);
|
||||||
|
};
|
||||||
|
|
||||||
|
const resolve = value => {
|
||||||
|
resolve_(value);
|
||||||
|
cleanup();
|
||||||
|
};
|
||||||
|
|
||||||
|
const reject = reason => {
|
||||||
|
isRejected = true;
|
||||||
|
isResolved = true;
|
||||||
|
reject_(reason);
|
||||||
|
cleanup();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (signal) {
|
||||||
|
if (signal.aborted) {
|
||||||
|
reject(signal.reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
signal.addEventListener('abort', signalListener, {once: true});
|
||||||
|
}
|
||||||
|
|
||||||
|
const next = async () => {
|
||||||
|
if (isResolved) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextItem = await iterator.next();
|
||||||
|
|
||||||
|
const index = currentIndex;
|
||||||
|
currentIndex++;
|
||||||
|
|
||||||
|
// Note: `iterator.next()` can be called many times in parallel.
|
||||||
|
// This can cause multiple calls to this `next()` function to
|
||||||
|
// receive a `nextItem` with `done === true`.
|
||||||
|
// The shutdown logic that rejects/resolves must be protected
|
||||||
|
// so it runs only one time as the `skippedIndex` logic is
|
||||||
|
// non-idempotent.
|
||||||
|
if (nextItem.done) {
|
||||||
|
isIterableDone = true;
|
||||||
|
|
||||||
|
if (resolvingCount === 0 && !isResolved) {
|
||||||
|
if (!stopOnError && errors.length > 0) {
|
||||||
|
reject(new AggregateError(errors)); // eslint-disable-line unicorn/error-message
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isResolved = true;
|
||||||
|
|
||||||
|
if (skippedIndexesMap.size === 0) {
|
||||||
|
resolve(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const pureResult = [];
|
||||||
|
|
||||||
|
// Support multiple `pMapSkip`'s.
|
||||||
|
for (const [index, value] of result.entries()) {
|
||||||
|
if (skippedIndexesMap.get(index) === pMapSkip) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
pureResult.push(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(pureResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resolvingCount++;
|
||||||
|
|
||||||
|
// Intentionally detached
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const element = await nextItem.value;
|
||||||
|
|
||||||
|
if (isResolved) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const value = await mapper(element, index);
|
||||||
|
|
||||||
|
// Use Map to stage the index of the element.
|
||||||
|
if (value === pMapSkip) {
|
||||||
|
skippedIndexesMap.set(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
result[index] = value;
|
||||||
|
|
||||||
|
resolvingCount--;
|
||||||
|
await next();
|
||||||
|
} catch (error) {
|
||||||
|
if (stopOnError) {
|
||||||
|
reject(error);
|
||||||
|
} else {
|
||||||
|
errors.push(error);
|
||||||
|
resolvingCount--;
|
||||||
|
|
||||||
|
// In that case we can't really continue regardless of `stopOnError` state
|
||||||
|
// since an iterable is likely to continue throwing after it throws once.
|
||||||
|
// If we continue calling `next()` indefinitely we will likely end up
|
||||||
|
// in an infinite loop of failed iteration.
|
||||||
|
try {
|
||||||
|
await next();
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create the concurrent runners in a detached (non-awaited)
|
||||||
|
// promise. We need this so we can await the `next()` calls
|
||||||
|
// to stop creating runners before hitting the concurrency limit
|
||||||
|
// if the iterable has already been marked as done.
|
||||||
|
// NOTE: We *must* do this for async iterators otherwise we'll spin up
|
||||||
|
// infinite `next()` calls by default and never start the event loop.
|
||||||
|
(async () => {
|
||||||
|
for (let index = 0; index < concurrency; index++) {
|
||||||
|
try {
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await next();
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isIterableDone || isRejected) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function pMapIterable(
|
||||||
|
iterable,
|
||||||
|
mapper,
|
||||||
|
{
|
||||||
|
concurrency = Number.POSITIVE_INFINITY,
|
||||||
|
backpressure = concurrency,
|
||||||
|
} = {},
|
||||||
|
) {
|
||||||
|
if (iterable[Symbol.iterator] === undefined && iterable[Symbol.asyncIterator] === undefined) {
|
||||||
|
throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof mapper !== 'function') {
|
||||||
|
throw new TypeError('Mapper function is required');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!((Number.isSafeInteger(concurrency) && concurrency >= 1) || concurrency === Number.POSITIVE_INFINITY)) {
|
||||||
|
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!((Number.isSafeInteger(backpressure) && backpressure >= concurrency) || backpressure === Number.POSITIVE_INFINITY)) {
|
||||||
|
throw new TypeError(`Expected \`backpressure\` to be an integer from \`concurrency\` (${concurrency}) and up or \`Infinity\`, got \`${backpressure}\` (${typeof backpressure})`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
async * [Symbol.asyncIterator]() {
|
||||||
|
const iterator = iterable[Symbol.asyncIterator] === undefined ? iterable[Symbol.iterator]() : iterable[Symbol.asyncIterator]();
|
||||||
|
|
||||||
|
const promises = [];
|
||||||
|
let runningMappersCount = 0;
|
||||||
|
let isDone = false;
|
||||||
|
let index = 0;
|
||||||
|
|
||||||
|
function trySpawn() {
|
||||||
|
if (isDone || !(runningMappersCount < concurrency && promises.length < backpressure)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const promise = (async () => {
|
||||||
|
const {done, value} = await iterator.next();
|
||||||
|
|
||||||
|
if (done) {
|
||||||
|
return {done: true};
|
||||||
|
}
|
||||||
|
|
||||||
|
runningMappersCount++;
|
||||||
|
|
||||||
|
// Spawn if still below concurrency and backpressure limit
|
||||||
|
trySpawn();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const returnValue = await mapper(await value, index++);
|
||||||
|
|
||||||
|
runningMappersCount--;
|
||||||
|
|
||||||
|
if (returnValue === pMapSkip) {
|
||||||
|
const index = promises.indexOf(promise);
|
||||||
|
|
||||||
|
if (index > 0) {
|
||||||
|
promises.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spawn if still below backpressure limit and just dropped below concurrency limit
|
||||||
|
trySpawn();
|
||||||
|
|
||||||
|
return {done: false, value: returnValue};
|
||||||
|
} catch (error) {
|
||||||
|
isDone = true;
|
||||||
|
return {error};
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
promises.push(promise);
|
||||||
|
}
|
||||||
|
|
||||||
|
trySpawn();
|
||||||
|
|
||||||
|
while (promises.length > 0) {
|
||||||
|
const {error, done, value} = await promises[0]; // eslint-disable-line no-await-in-loop
|
||||||
|
|
||||||
|
promises.shift();
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (done) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spawn if just dropped below backpressure limit and below the concurrency limit
|
||||||
|
trySpawn();
|
||||||
|
|
||||||
|
if (value === pMapSkip) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const pMapSkip = Symbol('skip');
|
||||||
|
|
||||||
|
|
||||||
|
/***/ })
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//# sourceMappingURL=606.index.js.map
|
||||||
1
dist/606.index.js.map
generated
vendored
Normal file
1
dist/606.index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
103
dist/index.js
generated
vendored
103
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
4045
dist/licenses.txt
generated
vendored
4045
dist/licenses.txt
generated
vendored
File diff suppressed because it is too large
Load Diff
3
dist/package.json
generated
vendored
Normal file
3
dist/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"type": "module"
|
||||||
|
}
|
||||||
1
dist/sourcemap-register.cjs
generated
vendored
Normal file
1
dist/sourcemap-register.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/sourcemap-register.js
generated
vendored
1
dist/sourcemap-register.js
generated
vendored
File diff suppressed because one or more lines are too long
52
eslint.config.mjs
Normal file
52
eslint.config.mjs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import {defineConfig} from 'eslint/config';
|
||||||
|
import js from '@eslint/js';
|
||||||
|
import tseslint from '@typescript-eslint/eslint-plugin';
|
||||||
|
import vitest from '@vitest/eslint-plugin';
|
||||||
|
import globals from 'globals';
|
||||||
|
import eslintConfigPrettier from 'eslint-config-prettier/flat';
|
||||||
|
import eslintPluginPrettier from 'eslint-plugin-prettier';
|
||||||
|
|
||||||
|
export default defineConfig([
|
||||||
|
{
|
||||||
|
ignores: ['.yarn/**/*', 'coverage/**/*', 'dist/**/*']
|
||||||
|
},
|
||||||
|
js.configs.recommended,
|
||||||
|
...tseslint.configs['flat/recommended'],
|
||||||
|
eslintConfigPrettier,
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.node
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['__tests__/**'],
|
||||||
|
...vitest.configs.recommended,
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.node,
|
||||||
|
...vitest.environments.env.globals
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...vitest.configs.recommended.rules,
|
||||||
|
'vitest/no-conditional-expect': 'error',
|
||||||
|
'vitest/no-disabled-tests': 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
prettier: eslintPluginPrettier
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'prettier/prettier': 'error',
|
||||||
|
'@typescript-eslint/no-require-imports': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
allowAsImport: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
import fs from 'fs';
|
|
||||||
import os from 'os';
|
|
||||||
import path from 'path';
|
|
||||||
|
|
||||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-metadata-action-'));
|
|
||||||
|
|
||||||
process.env = Object.assign({}, process.env, {
|
|
||||||
TEMP: tmpDir,
|
|
||||||
GITHUB_REPOSITORY: 'docker/metadata-action',
|
|
||||||
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
|
|
||||||
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
|
|
||||||
}) as {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
clearMocks: true,
|
|
||||||
testEnvironment: 'node',
|
|
||||||
moduleFileExtensions: ['js', 'ts'],
|
|
||||||
setupFiles: ['dotenv/config'],
|
|
||||||
testMatch: ['**/*.test.ts'],
|
|
||||||
transform: {
|
|
||||||
'^.+\\.ts$': 'ts-jest'
|
|
||||||
},
|
|
||||||
moduleNameMapper: {
|
|
||||||
'^csv-parse/sync': '<rootDir>/node_modules/csv-parse/dist/cjs/sync.cjs'
|
|
||||||
},
|
|
||||||
collectCoverageFrom: ['src/**/{!(main.ts),}.ts'],
|
|
||||||
coveragePathIgnorePatterns: ['lib/', 'node_modules/', '__mocks__/', '__tests__/'],
|
|
||||||
verbose: true
|
|
||||||
};
|
|
||||||
57
package.json
57
package.json
@@ -1,16 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "docker-metadata-action",
|
"name": "docker-metadata-action",
|
||||||
"description": "GitHub Action to extract metadata (tags, labels) for Docker",
|
"description": "GitHub Action to extract metadata (tags, labels) for Docker",
|
||||||
|
"type": "module",
|
||||||
"main": "src/main.ts",
|
"main": "src/main.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ncc build --source-map --minify --license licenses.txt",
|
"build": "ncc build --source-map --minify --license licenses.txt",
|
||||||
"lint": "yarn run prettier && yarn run eslint",
|
"lint": "eslint --max-warnings=0 .",
|
||||||
"format": "yarn run prettier:fix && yarn run eslint:fix",
|
"format": "eslint --fix .",
|
||||||
"eslint": "eslint --max-warnings=0 .",
|
"test": "vitest run"
|
||||||
"eslint:fix": "eslint --fix .",
|
|
||||||
"prettier": "prettier --check \"./**/*.ts\"",
|
|
||||||
"prettier:fix": "prettier --write \"./**/*.ts\"",
|
|
||||||
"test": "jest"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -25,34 +22,34 @@
|
|||||||
],
|
],
|
||||||
"author": "Docker Inc.",
|
"author": "Docker Inc.",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"packageManager": "yarn@3.6.3",
|
"packageManager": "yarn@4.9.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.11.1",
|
"@actions/core": "^3.0.0",
|
||||||
"@actions/github": "^6.0.0",
|
"@actions/github": "^6.0.1",
|
||||||
"@docker/actions-toolkit": "^0.56.0",
|
"@docker/actions-toolkit": "^0.68.0",
|
||||||
"@renovate/pep440": "^1.0.0",
|
"@renovate/pep440": "^1.0.0",
|
||||||
"csv-parse": "^5.6.0",
|
"csv-parse": "^6.1.0",
|
||||||
"handlebars": "^4.7.8",
|
"handlebars": "^4.7.8",
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.30.1",
|
||||||
"moment-timezone": "^0.5.47",
|
"moment-timezone": "^0.6.0",
|
||||||
"semver": "^7.7.1"
|
"semver": "^7.7.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/csv-parse": "^1.2.2",
|
"@eslint/js": "^9.39.3",
|
||||||
"@types/node": "^20.12.12",
|
"@types/node": "^20.19.35",
|
||||||
"@types/semver": "^7.5.8",
|
"@types/semver": "^7.7.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.9.0",
|
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
||||||
"@typescript-eslint/parser": "^7.9.0",
|
"@typescript-eslint/parser": "^8.56.1",
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.4",
|
||||||
"dotenv": "^16.4.5",
|
"@vitest/coverage-v8": "^4.0.18",
|
||||||
"eslint": "^8.57.0",
|
"@vitest/eslint-plugin": "^1.6.9",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"dotenv": "^17.3.1",
|
||||||
"eslint-plugin-jest": "^28.5.0",
|
"eslint": "^9.39.3",
|
||||||
"eslint-plugin-prettier": "^5.1.3",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"jest": "^29.7.0",
|
"eslint-plugin-prettier": "^5.5.5",
|
||||||
"prettier": "^3.2.5",
|
"globals": "^17.3.0",
|
||||||
"ts-jest": "^29.1.2",
|
"prettier": "^3.8.1",
|
||||||
"ts-node": "^10.9.2",
|
"typescript": "^5.9.3",
|
||||||
"typescript": "^5.4.5"
|
"vitest": "^4.0.18"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {Context as GithubContext} from '@actions/github/lib/context';
|
|
||||||
import {Util} from '@docker/actions-toolkit/lib/util';
|
import {Context as GithubContext} from '@actions/github/lib/context.js';
|
||||||
import {Git} from '@docker/actions-toolkit/lib/git';
|
import {Util} from '@docker/actions-toolkit/lib/util.js';
|
||||||
import {GitHub} from '@docker/actions-toolkit/lib/github';
|
import {Git} from '@docker/actions-toolkit/lib/git.js';
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
import {GitHub} from '@docker/actions-toolkit/lib/github.js';
|
||||||
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit.js';
|
||||||
|
|
||||||
export interface Context extends GithubContext {
|
export interface Context extends GithubContext {
|
||||||
commitDate: Date;
|
commitDate: Date;
|
||||||
|
|||||||
11
src/main.ts
11
src/main.ts
@@ -1,11 +1,11 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as actionsToolkit from '@docker/actions-toolkit';
|
import * as actionsToolkit from '@docker/actions-toolkit';
|
||||||
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
|
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit.js';
|
||||||
import {Util} from '@docker/actions-toolkit/lib/util';
|
import {Util} from '@docker/actions-toolkit/lib/util.js';
|
||||||
|
|
||||||
import {getContext, getInputs, Inputs} from './context';
|
import {getContext, getInputs, Inputs} from './context.js';
|
||||||
import {Meta, Version} from './meta';
|
import {Meta, Version} from './meta.js';
|
||||||
|
|
||||||
actionsToolkit.run(
|
actionsToolkit.run(
|
||||||
// main
|
// main
|
||||||
@@ -47,7 +47,7 @@ actionsToolkit.run(
|
|||||||
setOutput('version', version.main || '');
|
setOutput('version', version.main || '');
|
||||||
|
|
||||||
// Docker tags
|
// Docker tags
|
||||||
const tags: Array<string> = meta.getTags();
|
const tags = meta.getTags();
|
||||||
if (tags.length == 0) {
|
if (tags.length == 0) {
|
||||||
core.warning('No Docker tag has been generated. Check tags input.');
|
core.warning('No Docker tag has been generated. Check tags input.');
|
||||||
} else {
|
} else {
|
||||||
@@ -58,6 +58,7 @@ actionsToolkit.run(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
setOutput('tags', tags.join(inputs.sepTags));
|
setOutput('tags', tags.join(inputs.sepTags));
|
||||||
|
setOutput('tag-names', meta.getTags(true).join(inputs.sepTags));
|
||||||
|
|
||||||
// Docker labels
|
// Docker labels
|
||||||
const labels: Array<string> = meta.getLabels();
|
const labels: Array<string> = meta.getLabels();
|
||||||
|
|||||||
84
src/meta.ts
84
src/meta.ts
@@ -5,13 +5,13 @@ import moment from 'moment-timezone';
|
|||||||
import * as pep440 from '@renovate/pep440';
|
import * as pep440 from '@renovate/pep440';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {Context as ToolkitContext} from '@docker/actions-toolkit/lib/context';
|
import {Context as ToolkitContext} from '@docker/actions-toolkit/lib/context.js';
|
||||||
import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github';
|
import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github.js';
|
||||||
|
|
||||||
import {Inputs, Context} from './context';
|
import {Inputs, Context} from './context.js';
|
||||||
import * as icl from './image';
|
import * as icl from './image.js';
|
||||||
import * as tcl from './tag';
|
import * as tcl from './tag.js';
|
||||||
import * as fcl from './flavor';
|
import * as fcl from './flavor.js';
|
||||||
|
|
||||||
const defaultShortShaLength = 7;
|
const defaultShortShaLength = 7;
|
||||||
|
|
||||||
@@ -161,8 +161,20 @@ export class Meta {
|
|||||||
if (tag.attrs['value'].length > 0) {
|
if (tag.attrs['value'].length > 0) {
|
||||||
vraw = this.setGlobalExp(tag.attrs['value']);
|
vraw = this.setGlobalExp(tag.attrs['value']);
|
||||||
} else {
|
} else {
|
||||||
vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
vraw = this.context.ref.replace(/^refs\/tags\//g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tag.attrs['match'].length > 0) {
|
||||||
|
const tmatch = vraw.match(tag.attrs['match']);
|
||||||
|
if (!tmatch) {
|
||||||
|
core.warning(`${tag.attrs['match']} does not match ${vraw}.`);
|
||||||
|
} else {
|
||||||
|
vraw = tmatch[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vraw = vraw.replace(/\//g, '-');
|
||||||
|
|
||||||
if (!semver.valid(vraw)) {
|
if (!semver.valid(vraw)) {
|
||||||
core.warning(`${vraw} is not a valid semver. More info: https://semver.org/`);
|
core.warning(`${vraw} is not a valid semver. More info: https://semver.org/`);
|
||||||
return version;
|
return version;
|
||||||
@@ -195,8 +207,20 @@ export class Meta {
|
|||||||
if (tag.attrs['value'].length > 0) {
|
if (tag.attrs['value'].length > 0) {
|
||||||
vraw = this.setGlobalExp(tag.attrs['value']);
|
vraw = this.setGlobalExp(tag.attrs['value']);
|
||||||
} else {
|
} else {
|
||||||
vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
vraw = this.context.ref.replace(/^refs\/tags\//g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tag.attrs['match'].length > 0) {
|
||||||
|
const tmatch = vraw.match(tag.attrs['match']);
|
||||||
|
if (!tmatch) {
|
||||||
|
core.warning(`${tag.attrs['match']} does not match ${vraw}.`);
|
||||||
|
} else {
|
||||||
|
vraw = tmatch[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vraw = vraw.replace(/\//g, '-');
|
||||||
|
|
||||||
if (!pep440.valid(vraw)) {
|
if (!pep440.valid(vraw)) {
|
||||||
core.warning(`${vraw} does not conform to PEP 440. More info: https://www.python.org/dev/peps/pep-0440`);
|
core.warning(`${vraw} does not conform to PEP 440. More info: https://www.python.org/dev/peps/pep-0440`);
|
||||||
return version;
|
return version;
|
||||||
@@ -352,7 +376,7 @@ export class Meta {
|
|||||||
if (hp.body.length == 1 && hp.body[0].type == 'MustacheStatement') {
|
if (hp.body.length == 1 && hp.body[0].type == 'MustacheStatement') {
|
||||||
return hp.body[0]['path']['parts'].length == 1 && hp.body[0]['path']['parts'][0] == 'raw';
|
return hp.body[0]['path']['parts'].length == 1 && hp.body[0]['path']['parts'][0] == 'raw';
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -439,6 +463,9 @@ export class Meta {
|
|||||||
}
|
}
|
||||||
return 'false';
|
return 'false';
|
||||||
},
|
},
|
||||||
|
is_not_default_branch: function () {
|
||||||
|
return this.is_default_branch() === 'false' ? 'true' : 'false';
|
||||||
|
},
|
||||||
date: function (format, options) {
|
date: function (format, options) {
|
||||||
const m = moment(currentDate);
|
const m = moment(currentDate);
|
||||||
let tz = 'UTC';
|
let tz = 'UTC';
|
||||||
@@ -467,33 +494,37 @@ export class Meta {
|
|||||||
return images;
|
return images;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTags(): Array<string> {
|
public getTags(namesOnly?: boolean): Array<string> {
|
||||||
if (!this.version.main) {
|
if (!this.version.main) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
if (namesOnly) {
|
||||||
const generateTags = (imageName: string, version: string): Array<string> => {
|
return this.generateTags(this.version.main);
|
||||||
const tags: Array<string> = [];
|
}
|
||||||
const prefix = imageName !== '' ? `${imageName}:` : '';
|
|
||||||
tags.push(`${prefix}${version}`);
|
|
||||||
for (const partial of this.version.partial) {
|
|
||||||
tags.push(`${prefix}${partial}`);
|
|
||||||
}
|
|
||||||
if (this.version.latest) {
|
|
||||||
const latestTag = `${this.flavor.prefixLatest ? this.flavor.prefix : ''}latest${this.flavor.suffixLatest ? this.flavor.suffix : ''}`;
|
|
||||||
tags.push(`${prefix}${Meta.sanitizeTag(latestTag)}`);
|
|
||||||
}
|
|
||||||
return tags;
|
|
||||||
};
|
|
||||||
|
|
||||||
const tags: Array<string> = [];
|
const tags: Array<string> = [];
|
||||||
const images = this.getImageNames();
|
const images = this.getImageNames();
|
||||||
if (images.length > 0) {
|
if (images.length > 0) {
|
||||||
for (const imageName of images) {
|
for (const imageName of images) {
|
||||||
tags.push(...generateTags(imageName, this.version.main));
|
tags.push(...this.generateTags(this.version.main, imageName));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tags.push(...generateTags('', this.version.main));
|
tags.push(...this.generateTags(this.version.main));
|
||||||
|
}
|
||||||
|
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
private generateTags(version: string, imageName?: string): Array<string> {
|
||||||
|
const tags: Array<string> = [];
|
||||||
|
const prefix = imageName ? `${imageName}:` : '';
|
||||||
|
tags.push(`${prefix}${version}`);
|
||||||
|
for (const partial of this.version.partial) {
|
||||||
|
tags.push(`${prefix}${partial}`);
|
||||||
|
}
|
||||||
|
if (this.version.latest) {
|
||||||
|
const latestTag = `${this.flavor.prefixLatest ? this.flavor.prefix : ''}latest${this.flavor.suffixLatest ? this.flavor.suffix : ''}`;
|
||||||
|
tags.push(`${prefix}${Meta.sanitizeTag(latestTag)}`);
|
||||||
}
|
}
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
@@ -541,6 +572,7 @@ export class Meta {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
tags: this.getTags(),
|
tags: this.getTags(),
|
||||||
|
'tag-names': this.getTags(true),
|
||||||
labels: this.getLabels().reduce((res, label) => {
|
labels: this.getLabels().reduce((res, label) => {
|
||||||
const matches = label.match(/([^=]*)=(.*)/);
|
const matches = label.match(/([^=]*)=(.*)/);
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
|
|||||||
@@ -104,10 +104,10 @@ export function Parse(s: string): Tag {
|
|||||||
const value = parts[1];
|
const value = parts[1];
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'type': {
|
case 'type': {
|
||||||
if (!Object.values(Type).includes(value)) {
|
if (!Object.values(Type).includes(value as Type)) {
|
||||||
throw new Error(`Unknown tag type attribute: ${value}`);
|
throw new Error(`Unknown tag type attribute: ${value}`);
|
||||||
}
|
}
|
||||||
tag.type = value;
|
tag.type = value as Type;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@@ -137,6 +137,9 @@ export function Parse(s: string): Tag {
|
|||||||
if (!Object.prototype.hasOwnProperty.call(tag.attrs, 'value')) {
|
if (!Object.prototype.hasOwnProperty.call(tag.attrs, 'value')) {
|
||||||
tag.attrs['value'] = '';
|
tag.attrs['value'] = '';
|
||||||
}
|
}
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(tag.attrs, 'match')) {
|
||||||
|
tag.attrs['match'] = '';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Type.Match: {
|
case Type.Match: {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"module": "nodenext",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"target": "es6",
|
|
||||||
"module": "commonjs",
|
|
||||||
"strict": true,
|
|
||||||
"newLine": "lf",
|
"newLine": "lf",
|
||||||
"outDir": "./lib",
|
"outDir": "./lib",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
@@ -12,11 +11,7 @@
|
|||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"useUnknownInCatchVariables": false,
|
"useUnknownInCatchVariables": false,
|
||||||
},
|
},
|
||||||
"exclude": [
|
"include": [
|
||||||
"./__mocks__/**/*",
|
"src/**/*.ts"
|
||||||
"./__tests__/**/*",
|
|
||||||
"./lib/**/*",
|
|
||||||
"node_modules",
|
|
||||||
"jest.config.ts"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
16
vitest.config.ts
Normal file
16
vitest.config.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import {defineConfig} from 'vitest/config';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
clearMocks: true,
|
||||||
|
environment: 'node',
|
||||||
|
setupFiles: ['./__tests__/setup.unit.ts'],
|
||||||
|
include: ['**/*.test.ts'],
|
||||||
|
coverage: {
|
||||||
|
provider: 'v8',
|
||||||
|
reporter: ['clover'],
|
||||||
|
include: ['src/**/*.ts'],
|
||||||
|
exclude: ['src/**/main.ts']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user