Compare commits
36 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2af9c6a52b | ||
|
1239e23120 | ||
|
8d3d13fe48 | ||
|
ed01528979 | ||
|
c8b87a08b5 | ||
|
280367084a | ||
|
c0bab712bd | ||
|
9ceaaf86cd | ||
|
f02d9f4f9b | ||
|
400bd87b5a | ||
|
e4fc7e9e11 | ||
|
9583a0f404 | ||
|
5e6d5157fb | ||
|
e09df4df3c | ||
|
72e5d60481 | ||
|
ae431178c1 | ||
|
34ebfd6e6b | ||
|
94641ff1bb | ||
|
40bfc8b527 | ||
|
2e1a5c7fa4 | ||
|
1a678de43d | ||
|
84b9e75d44 | ||
|
f39f06a624 | ||
|
36ae18e02c | ||
|
e87dd9466c | ||
|
9da1e66de9 | ||
|
521a3c5ada | ||
|
7433b42479 | ||
|
1a8a264b95 | ||
|
e04b4d01a9 | ||
|
ac90ddf06e | ||
|
972129059a | ||
|
b909bd34ef | ||
|
72654174f7 | ||
|
4545671ec8 | ||
|
5c38e5df03 |
@@ -1,5 +1,2 @@
|
||||
/.dev
|
||||
/coverage
|
||||
/dist
|
||||
/lib
|
||||
/node_modules
|
||||
|
10
.github/CONTRIBUTING.md
vendored
10
.github/CONTRIBUTING.md
vendored
@@ -2,19 +2,19 @@
|
||||
|
||||
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
|
||||
|
||||
Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license)
|
||||
Contributions to this project are [released](https://docs.github.com/en/github/site-policy/github-terms-of-service#6-contributions-under-repository-license)
|
||||
to the public under the [project's open source license](LICENSE).
|
||||
|
||||
## Submitting a pull request
|
||||
|
||||
1. [Fork](https://github.com/crazy-max/ghaction-docker-meta/fork) and clone the repository
|
||||
1. [Fork](https://github.com/docker/metadata-action/fork) and clone the repository
|
||||
2. Configure and install the dependencies: `yarn install`
|
||||
3. Create a new branch: `git checkout -b my-branch-name`
|
||||
4. Make your changes
|
||||
5. Make sure the tests pass: `docker buildx bake test`
|
||||
6. Format code and build javascript artifacts: `docker buildx bake pre-checkin`
|
||||
7. Validate all code has correctly formatted and built: `docker buildx bake validate`
|
||||
8. Push to your fork and [submit a pull request](https://github.com/crazy-max/ghaction-docker-meta/compare)
|
||||
8. Push to your fork and [submit a pull request](https://github.com/docker/metadata-action/compare)
|
||||
9. Pat your self on the back and wait for your pull request to be reviewed and merged.
|
||||
|
||||
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
|
||||
@@ -28,5 +28,5 @@ Here are a few things you can do that will increase the likelihood of your pull
|
||||
## Resources
|
||||
|
||||
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
||||
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
|
||||
- [GitHub Help](https://help.github.com)
|
||||
- [Using Pull Requests](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests)
|
||||
- [GitHub Help](https://docs.github.com/en)
|
||||
|
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -1,2 +0,0 @@
|
||||
github: crazy-max
|
||||
custom: https://www.paypal.me/crazyws
|
7
.github/ISSUE_TEMPLATE/bug_report.md
vendored
7
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -13,11 +13,11 @@ about: Create a report to help us improve
|
||||
|
||||
#### Expected behaviour
|
||||
|
||||
> Tell me what should happen
|
||||
> Tell us what should happen
|
||||
|
||||
#### Actual behaviour
|
||||
|
||||
> Tell me what happens instead
|
||||
> Tell us what happens instead
|
||||
|
||||
### Configuration
|
||||
|
||||
@@ -30,4 +30,5 @@ about: Create a report to help us improve
|
||||
|
||||
### Logs
|
||||
|
||||
> Download the [log file of your build](https://help.github.com/en/actions/configuring-and-managing-workflows/managing-a-workflow-run#downloading-logs) and [attach it](https://help.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue.
|
||||
> Download the [log file of your build](https://docs.github.com/en/actions/managing-workflow-runs/using-workflow-run-logs#downloading-logs)
|
||||
> and [attach it](https://docs.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue.
|
||||
|
13
.github/SUPPORT.md
vendored
13
.github/SUPPORT.md
vendored
@@ -1,10 +1,13 @@
|
||||
# Support [](https://isitmaintained.com/project/crazy-max/ghaction-docker-meta)
|
||||
# Support [](https://isitmaintained.com/project/docker/metadata-action)
|
||||
|
||||
## Reporting an issue
|
||||
|
||||
Please do a search in [open issues](https://github.com/crazy-max/ghaction-docker-meta/issues?utf8=%E2%9C%93&q=) to see if the issue or feature request has already been filed.
|
||||
Please do a search in [open issues](https://github.com/docker/metadata-action/issues?utf8=%E2%9C%93&q=) to see if the
|
||||
issue or feature request has already been filed.
|
||||
|
||||
If you find your issue already exists, make relevant comments and add your [reaction](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments). Use a reaction in place of a "+1" comment.
|
||||
If you find your issue already exists, make relevant comments and add your
|
||||
[reaction](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments). Use a reaction in place
|
||||
of a "+1" comment.
|
||||
|
||||
:+1: - upvote
|
||||
|
||||
@@ -21,9 +24,9 @@ File a single issue per problem and feature request.
|
||||
|
||||
The more information you can provide, the more likely someone will be successful reproducing the issue and finding a fix.
|
||||
|
||||
You are now ready to [create a new issue](https://github.com/crazy-max/ghaction-docker-meta/issues/new/choose)!
|
||||
You are now ready to [create a new issue](https://github.com/docker/metadata-action/issues/new/choose)!
|
||||
|
||||
## Closure policy
|
||||
|
||||
* Issues that don't have the information requested above (when applicable) will be closed immediately and the poster directed to the support guidelines.
|
||||
* Issues that go a week without a response from original poster are subject to closure at my discretion.
|
||||
* Issues that go a week without a response from original poster are subject to closure at our discretion.
|
||||
|
BIN
.github/ghaction-docker-meta.png
vendored
BIN
.github/ghaction-docker-meta.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 6.5 KiB |
85
.github/labels.yml
vendored
85
.github/labels.yml
vendored
@@ -1,85 +0,0 @@
|
||||
## more info https://github.com/crazy-max/ghaction-github-labeler
|
||||
- # automerge
|
||||
name: ":bell: automerge"
|
||||
color: "8f4fbc"
|
||||
description: ""
|
||||
- # bot
|
||||
name: ":robot: bot"
|
||||
color: "69cde9"
|
||||
description: ""
|
||||
- # bug
|
||||
name: ":bug: bug"
|
||||
color: "b60205"
|
||||
description: ""
|
||||
- # dependencies
|
||||
name: ":game_die: dependencies"
|
||||
color: "0366d6"
|
||||
description: ""
|
||||
- # documentation
|
||||
name: ":memo: documentation"
|
||||
color: "c5def5"
|
||||
description: ""
|
||||
- # duplicate
|
||||
name: ":busts_in_silhouette: duplicate"
|
||||
color: "cccccc"
|
||||
description: ""
|
||||
- # enhancement
|
||||
name: ":sparkles: enhancement"
|
||||
color: "0054ca"
|
||||
description: ""
|
||||
- # feature request
|
||||
name: ":bulb: feature request"
|
||||
color: "0e8a16"
|
||||
description: ""
|
||||
- # feedback
|
||||
name: ":mega: feedback"
|
||||
color: "03a9f4"
|
||||
description: ""
|
||||
- # future maybe
|
||||
name: ":rocket: future maybe"
|
||||
color: "fef2c0"
|
||||
description: ""
|
||||
- # good first issue
|
||||
name: ":hatching_chick: good first issue"
|
||||
color: "7057ff"
|
||||
description: ""
|
||||
- # help wanted
|
||||
name: ":pray: help wanted"
|
||||
color: "4caf50"
|
||||
description: ""
|
||||
- # invalid
|
||||
name: ":no_entry_sign: invalid"
|
||||
color: "e6e6e6"
|
||||
description: ""
|
||||
- # investigate
|
||||
name: ":mag: investigate"
|
||||
color: "e6625b"
|
||||
description: ""
|
||||
- # needs more info
|
||||
name: ":thinking: needs more info"
|
||||
color: "795548"
|
||||
description: ""
|
||||
- # pinned
|
||||
name: ":pushpin: pinned"
|
||||
color: "28008e"
|
||||
description: ""
|
||||
- # question
|
||||
name: ":question: question"
|
||||
color: "3f51b5"
|
||||
description: ""
|
||||
- # sponsor
|
||||
name: ":sparkling_heart: sponsor"
|
||||
color: "fedbf0"
|
||||
description: ""
|
||||
- # stale
|
||||
name: ":skull: stale"
|
||||
color: "237da0"
|
||||
description: ""
|
||||
- # upstream
|
||||
name: ":eyes: upstream"
|
||||
color: "fbca04"
|
||||
description: ""
|
||||
- # wontfix
|
||||
name: ":coffin: wontfix"
|
||||
color: "ffffff"
|
||||
description: ""
|
BIN
.github/metadata-action.png
vendored
Normal file
BIN
.github/metadata-action.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
19
.github/stale.yml
vendored
19
.github/stale.yml
vendored
@@ -1,19 +0,0 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 30
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- ":pushpin: pinned"
|
||||
- ":game_die: dependencies"
|
||||
# Set to true to ignore issues in a milestone (defaults to false)
|
||||
exemptMilestones: true
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: ":skull: stale"
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -72,9 +72,9 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- tag-match: '\d{1,3}.\d{1,3}.\d{1,3}'
|
||||
- tag-match: '\d.\d.\d'
|
||||
tag-match-group: '0'
|
||||
- tag-match: '\d{1,3}.\d{1,3}'
|
||||
- tag-match: '\d.\d'
|
||||
tag-match-group: '0'
|
||||
- tag-match: 'v(.*)'
|
||||
tag-match-group: '1'
|
||||
|
21
.github/workflows/label-sponsor.yml
vendored
21
.github/workflows/label-sponsor.yml
vendored
@@ -1,21 +0,0 @@
|
||||
name: label-sponsor
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- 'opened'
|
||||
issues:
|
||||
types:
|
||||
- 'opened'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Set sponsor label
|
||||
uses: JasonEtco/is-sponsor-label-action@024ac24f8b170abce078cad4ee748852369853c8
|
||||
with:
|
||||
label: ":sparkling_heart: sponsor"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
20
.github/workflows/labels.yml
vendored
20
.github/workflows/labels.yml
vendored
@@ -1,20 +0,0 @@
|
||||
name: labels
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
paths:
|
||||
- '.github/labels.yml'
|
||||
- '.github/workflows/labels.yml'
|
||||
|
||||
jobs:
|
||||
labeler:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Run Labeler
|
||||
uses: crazy-max/ghaction-github-labeler@v3
|
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -5,14 +5,10 @@ on:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'releases/v*'
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'releases/v*'
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
108
CHANGELOG.md
108
CHANGELOG.md
@@ -1,108 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## 2.0.0 (2021/03/29)
|
||||
|
||||
This release includes significant changes (#50). Please read the [upgrade notes](UPGRADE.md) for a smooth migration.
|
||||
`v1` is still available through [`releases/v1` branch](https://github.com/crazy-max/ghaction-docker-meta/tree/releases/v1).
|
||||
|
||||
* Add `tags` input
|
||||
* Inputs `tag-sha`, `tag-edge`, `tag-edge-branch`, `tag-semver`, `tag-match`, `tag-match-group`, `tag-schedule`, `tag-custom`, `tag-custom-only` have been removed and are now handled through the new `tags` input
|
||||
* Input `label-custom` renamed `labels`
|
||||
* Add `flavor` input to handle a global prefix, suffix and latest tag behavior (#13 #15 #41)
|
||||
* Input `tag-latest` removed (use `flavor` input instead)
|
||||
* Manage tag sorting through `priority` attribute in `tags` input (#27)
|
||||
* Explicit control over the conditions of each tag through `enable` attribute in `tags` input (#30)
|
||||
* Allow `semver` and `match` parsing for custom values (#25 #30)
|
||||
* Display warning message if not tag generated
|
||||
|
||||
## 1.12.0 (2021/03/19)
|
||||
|
||||
* Ignore commas for `label-custom` input (#48)
|
||||
* Bump handlebars from 4.7.6 to 4.7.7 (#44)
|
||||
* Bump csv-parse from 4.14.2 to 4.15.3 (#42 #45)
|
||||
|
||||
## 1.11.0 (2020/12/24)
|
||||
|
||||
* Inject `DOCKER_META_IMAGES` and `DOCKER_META_VERSION` args in bake definition (#37)
|
||||
|
||||
## 1.10.1 (2020/12/24)
|
||||
|
||||
* Missing entry in `action.yml`
|
||||
|
||||
## 1.10.0 (2020/12/24)
|
||||
|
||||
* Add `bake-file` output (#36)
|
||||
* Add `label-custom` input (#35)
|
||||
* Bump node-notifier from 8.0.0 to 8.0.1 (#33)
|
||||
* Update dev workflow (#32)
|
||||
|
||||
## 1.9.1 (2020/12/07)
|
||||
|
||||
* Replace forbidden chars derived from branch name (#31)
|
||||
* Bump semver from 7.3.2 to 7.3.4 (#26)
|
||||
|
||||
## 1.9.0 (2020/12/04)
|
||||
|
||||
* Allow to add custom tags (#24)
|
||||
* Allow to disable latest tag (#23)
|
||||
* Warn on invalid semver (#22)
|
||||
* Avoid unnecessary calls to version (#21)
|
||||
|
||||
## 1.8.5 (2020/11/24)
|
||||
|
||||
* Use sepLabels when joining labels for output (#17)
|
||||
|
||||
## 1.8.4 (2020/11/20)
|
||||
|
||||
* Pre-release (rc, beta, alpha) will only extend `{{version}}` as tag for `tag-semver`
|
||||
|
||||
## 1.8.3 (2020/11/20)
|
||||
|
||||
* Lowercase image name (#16)
|
||||
|
||||
## 1.8.2 (2020/11/18)
|
||||
|
||||
* Remove duplicated tags
|
||||
|
||||
## 1.8.1 (2020/11/18)
|
||||
|
||||
* Missing input in `action.yml`
|
||||
|
||||
## 1.8.0 (2020/11/17)
|
||||
|
||||
* Handle semver tags (#14)
|
||||
|
||||
## 1.7.0 (2020/10/31)
|
||||
|
||||
* Use `repo.html_url` for `org.opencontainers.image.source` label to be able to display README on GHCR
|
||||
* Handle `tag-match-latest` on Git tag event (#8)
|
||||
|
||||
## 1.6.0 (2020/10/28)
|
||||
|
||||
* Generate latest tag by default on push tag event (#5)
|
||||
|
||||
## 1.5.0 (2020/10/27)
|
||||
|
||||
* Add `tag-match-group` input to choose group to get if `tag-match` matches
|
||||
* Check `tag-match` is a valid regex
|
||||
|
||||
## 1.4.0 (2020/10/27)
|
||||
|
||||
* Use RegExp to match against a Git tag instead of coerce
|
||||
|
||||
## 1.3.0 (2020/10/26)
|
||||
|
||||
* Set latest tag only if matches with a pattern
|
||||
|
||||
## 1.2.0 (2020/10/26)
|
||||
|
||||
* Coerces Git tag to semver (#3)
|
||||
|
||||
## 1.1.0 (2020/10/25)
|
||||
|
||||
* Allow to templatize schedule tag (#1)
|
||||
* Allow to disable edge branch tagging (#2)
|
||||
|
||||
## 1.0.0 (2020/10/25)
|
||||
|
||||
* Initial version
|
204
LICENSE
204
LICENSE
@@ -1,21 +1,191 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2021 CrazyMax
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
https://www.apache.org/licenses/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
1. Definitions.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2013-2018 Docker, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
118
README.md
118
README.md
@@ -1,22 +1,14 @@
|
||||
[](https://github.com/crazy-max/ghaction-docker-meta/releases/latest)
|
||||
[](https://github.com/marketplace/actions/docker-meta)
|
||||
[](https://github.com/crazy-max/ghaction-docker-meta/actions?workflow=test)
|
||||
[](https://codecov.io/gh/crazy-max/ghaction-docker-meta)
|
||||
[](https://github.com/sponsors/crazy-max)
|
||||
[](https://www.paypal.me/crazyws)
|
||||
|
||||
## Upgrade from v1
|
||||
|
||||
`v2` of this action includes significant changes. Please read the [upgrade notes](UPGRADE.md) for a smooth migration.
|
||||
[](https://github.com/docker/metadata-action/releases/latest)
|
||||
[](https://github.com/marketplace/actions/docker-metadata-action)
|
||||
[](https://github.com/docker/metadata-action/actions?workflow=test)
|
||||
[](https://codecov.io/gh/docker/metadata-action)
|
||||
|
||||
## About
|
||||
|
||||
GitHub Action to extract metadata (tags, labels) for Docker. This action is particularly useful if used with
|
||||
[Docker Build Push](https://github.com/docker/build-push-action) action.
|
||||
|
||||
If you are interested, [check out](https://git.io/Je09Y) my other :octocat: GitHub Actions!
|
||||
|
||||

|
||||

|
||||
|
||||
___
|
||||
|
||||
@@ -38,10 +30,10 @@ ___
|
||||
* [`type=sha`](#typesha)
|
||||
* [Notes](#notes)
|
||||
* [Latest tag](#latest-tag)
|
||||
* [Global expressions](#global-expressions)
|
||||
* [Major version zero](#major-version-zero)
|
||||
* [Overwrite labels](#overwrite-labels)
|
||||
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
|
||||
* [Contributing](#contributing)
|
||||
* [License](#license)
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -70,7 +62,7 @@ jobs:
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: crazy-max/ghaction-docker-meta@v2
|
||||
uses: docker/metadata-action@v3
|
||||
with:
|
||||
images: name/app
|
||||
-
|
||||
@@ -123,12 +115,11 @@ jobs:
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: crazy-max/ghaction-docker-meta@v2
|
||||
uses: docker/metadata-action@v3
|
||||
with:
|
||||
images: name/app
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
@@ -161,14 +152,14 @@ jobs:
|
||||
|
||||
This action also handles a bake definition file that can be used with the
|
||||
[Docker Bake action](https://github.com/docker/bake-action). You just have to declare an empty target named
|
||||
`ghaction-docker-meta` and inherit from it.
|
||||
`docker-metadata-action` and inherit from it.
|
||||
|
||||
```hcl
|
||||
// docker-bake.hcl
|
||||
target "ghaction-docker-meta" {}
|
||||
target "docker-metadata-action" {}
|
||||
|
||||
target "build" {
|
||||
inherits = ["ghaction-docker-meta"]
|
||||
inherits = ["docker-metadata-action"]
|
||||
context = "./"
|
||||
dockerfile = "Dockerfile"
|
||||
platforms = ["linux/amd64", "linux/arm/v6", "linux/arm/v7", "linux/arm64", "linux/386", "linux/ppc64le"]
|
||||
@@ -195,12 +186,11 @@ jobs:
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: crazy-max/ghaction-docker-meta@v2
|
||||
uses: docker/metadata-action@v3
|
||||
with:
|
||||
images: name/app
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
@@ -220,7 +210,7 @@ Content of `${{ steps.meta.outputs.bake-file }}` file will look like this with `
|
||||
```json
|
||||
{
|
||||
"target": {
|
||||
"ghaction-docker-meta": {
|
||||
"docker-metadata-action": {
|
||||
"tags": [
|
||||
"name/app:1.2.3",
|
||||
"name/app:1.2",
|
||||
@@ -254,7 +244,7 @@ Following inputs can be used as `step.with` keys
|
||||
|
||||
> `List` type is a newline-delimited string
|
||||
> ```yaml
|
||||
> label-custom: |
|
||||
> labels: |
|
||||
> org.opencontainers.image.title=MyCustomTitle
|
||||
> org.opencontainers.image.description=Another description
|
||||
> org.opencontainers.image.vendor=MyCompany
|
||||
@@ -273,6 +263,7 @@ Following inputs can be used as `step.with` keys
|
||||
| `labels` | List | List of custom labels |
|
||||
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
|
||||
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
|
||||
| `bake-target` | String | Bake target name (default `docker-metadata-action`) |
|
||||
|
||||
### outputs
|
||||
|
||||
@@ -310,7 +301,6 @@ the form of a key-value pair list in CSV format to remove limitations intrinsica
|
||||
tags: |
|
||||
type=schedule
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
@@ -423,9 +413,7 @@ tags: |
|
||||
```yaml
|
||||
tags: |
|
||||
# minimal
|
||||
type=match,pattern=\d{8}
|
||||
# double quotes if comma in pattern
|
||||
type=match,"pattern=\d{1,3}.\d{1,3}.\d{1,3}"
|
||||
type=match,pattern=\d.\d.\d
|
||||
# define match group
|
||||
type=match,pattern=v(.*),group=1
|
||||
# use custom value instead of git tag
|
||||
@@ -438,16 +426,17 @@ a custom value through `value` attribute.
|
||||
|
||||
| Git tag | Pattern | Group | Output |
|
||||
|-------------------------|-------------------------------|---------|------------------------|
|
||||
| `v1.2.3` | `\d{1,3}.\d{1,3}.\d{1,3}` | `0` | `1.2.3` |
|
||||
| `v1.2.3` | `\d.\d.\d` | `0` | `1.2.3` |
|
||||
| `v2.0.8-beta.67` | `v(.*)` | `1` | `2.0.8-beta.67` |
|
||||
| `v2.0.8-beta.67` | `v(\d.\d)` | `1` | `2.0` |
|
||||
| `20200110-RC2` | `\d+` | `0` | `20200110` |
|
||||
| `p1/v1.2.3` | `p1-v(\d.\d.\d)` | `1` | `1.2.3` |
|
||||
|
||||
Extended attributes and default values:
|
||||
|
||||
```yaml
|
||||
tags: |
|
||||
type=group,enable=true,priority=800,prefix=,suffix=,pattern=,group=0,value=
|
||||
type=match,enable=true,priority=800,prefix=,suffix=,pattern=,group=0,value=
|
||||
```
|
||||
|
||||
### `type=edge`
|
||||
@@ -475,11 +464,11 @@ tags: |
|
||||
|
||||
```yaml
|
||||
tags: |
|
||||
# minimal branch event
|
||||
# branch event
|
||||
type=ref,event=branch
|
||||
# minimal tag event
|
||||
# tag event
|
||||
type=ref,event=tag
|
||||
# minimal pull request event
|
||||
# pull request event
|
||||
type=ref,event=pr
|
||||
```
|
||||
|
||||
@@ -500,11 +489,11 @@ Extended attributes and default values:
|
||||
|
||||
```yaml
|
||||
tags: |
|
||||
# event branch
|
||||
# branch event
|
||||
type=ref,enable=true,priority=600,prefix=,suffix=,event=
|
||||
# event tag
|
||||
# tag event
|
||||
type=ref,enable=true,priority=600,prefix=,suffix=,event=
|
||||
# event pr
|
||||
# pull request event
|
||||
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=
|
||||
```
|
||||
|
||||
@@ -557,6 +546,44 @@ tags: |
|
||||
* [`type=semver,pattern=...`](#typesemver)
|
||||
* [`type=match,pattern=...`](#typematch)
|
||||
|
||||
### Global expressions
|
||||
|
||||
The following [Handlebars template](https://handlebarsjs.com/guide/) expressions for `prefix`, `suffix` and `value`
|
||||
attributes are available:
|
||||
|
||||
| Expression | Output |
|
||||
|--------------------------|----------------------|
|
||||
| `{{branch}}` | `master` |
|
||||
| `{{tag}}` | `v1.2.3` |
|
||||
| `{{sha}}` | `90dd603` |
|
||||
|
||||
```yaml
|
||||
tags: |
|
||||
# dynamically set the branch name as a prefix
|
||||
type=sha,prefix={{branch}}-
|
||||
# dynamically set the branch name and sha as a custom tag
|
||||
type=raw,value=mytag-{{branch}}-{{sha}}
|
||||
```
|
||||
|
||||
### Major version zero
|
||||
|
||||
Major version zero (`0.y.z`) is for initial development and **may** change at any time. This means the public API
|
||||
[**should not** be considered stable](https://semver.org/#spec-item-4).
|
||||
|
||||
In this case, Docker tag `0` **should not** be generated if you're using [`type=semver`](#typesemver) with `{{major}}`
|
||||
pattern. You can manage this behavior like this:
|
||||
|
||||
```yaml
|
||||
# refs/tags/v0.1.2
|
||||
tags: |
|
||||
# output 0.1.2
|
||||
type=semver,pattern={{version}}
|
||||
# output 0.1
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
# disabled if major zero
|
||||
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
|
||||
```
|
||||
|
||||
### Overwrite labels
|
||||
|
||||
If some of the [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md)
|
||||
@@ -566,7 +593,7 @@ labels generated are not suitable, you can overwrite them like this:
|
||||
-
|
||||
name: Docker meta
|
||||
id: docker_meta
|
||||
uses: crazy-max/ghaction-docker-meta@v2
|
||||
uses: docker/metadata-action@v3
|
||||
with:
|
||||
images: name/app
|
||||
labels: |
|
||||
@@ -591,18 +618,3 @@ updates:
|
||||
schedule:
|
||||
interval: "daily"
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Want to contribute? Awesome! The most basic way to show your support is to star :star2: the project,
|
||||
or to raise issues :speech_balloon:. If you want to open a pull request, please read the
|
||||
[contributing guidelines](.github/CONTRIBUTING.md).
|
||||
|
||||
You can also support this project by [**becoming a sponsor on GitHub**](https://github.com/sponsors/crazy-max) or by
|
||||
making a [Paypal donation](https://www.paypal.me/crazyws) to ensure this journey continues indefinitely!
|
||||
|
||||
Thanks again for your support, it is much appreciated! :pray:
|
||||
|
||||
## License
|
||||
|
||||
MIT. See `LICENSE` for more details.
|
||||
|
18
UPGRADE.md
18
UPGRADE.md
@@ -1,5 +1,10 @@
|
||||
# Upgrade notes
|
||||
|
||||
## v2 to v3
|
||||
|
||||
* Repository has been moved to docker org. Replace `crazy-max/ghaction-docker-meta@v2` with `docker/metadata-action@v3`
|
||||
* The default bake target has been changed: `ghaction-docker-meta` > `docker-metadata-action`
|
||||
|
||||
## v1 to v2
|
||||
|
||||
* [inputs](#inputs)
|
||||
@@ -131,7 +136,7 @@ jobs:
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: crazy-max/ghaction-docker-meta@v1
|
||||
uses: docker/metadata-action@v1
|
||||
with:
|
||||
images: name/app
|
||||
-
|
||||
@@ -147,8 +152,8 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
```
|
||||
|
||||
```yaml
|
||||
@@ -175,7 +180,7 @@ jobs:
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: crazy-max/ghaction-docker-meta@v2
|
||||
uses: docker/metadata-action@v3
|
||||
with:
|
||||
images: name/app
|
||||
-
|
||||
@@ -221,7 +226,7 @@ jobs:
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: crazy-max/ghaction-docker-meta@v1
|
||||
uses: docker/metadata-action@v1
|
||||
with:
|
||||
images: name/app
|
||||
tag-semver: |
|
||||
@@ -268,12 +273,11 @@ jobs:
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: crazy-max/ghaction-docker-meta@v2
|
||||
uses: docker/metadata-action@v3
|
||||
with:
|
||||
images: name/app
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
|
||||
import * as context from '../src/context';
|
||||
|
||||
jest.spyOn(context, 'tmpDir').mockImplementation((): string => {
|
||||
const tmpDir = path.join('/tmp/.ghaction-docker-meta-jest').split(path.sep).join(path.posix.sep);
|
||||
const tmpDir = path.join('/tmp/.docker-metadata-action-jest').split(path.sep).join(path.posix.sep);
|
||||
if (!fs.existsSync(tmpDir)) {
|
||||
fs.mkdirSync(tmpDir, {recursive: true});
|
||||
}
|
||||
@@ -171,6 +172,27 @@ describe('asyncForEach', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('setOutput', () => {
|
||||
beforeEach(() => {
|
||||
process.stdout.write = jest.fn();
|
||||
});
|
||||
|
||||
it('setOutput produces the correct command', () => {
|
||||
context.setOutput('some output', 'some value');
|
||||
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
|
||||
});
|
||||
|
||||
it('setOutput handles bools', () => {
|
||||
context.setOutput('some output', false);
|
||||
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
|
||||
});
|
||||
|
||||
it('setOutput handles numbers', () => {
|
||||
context.setOutput('some output', 1.01);
|
||||
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
|
||||
});
|
||||
});
|
||||
|
||||
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
||||
function getInputName(name: string): string {
|
||||
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||
@@ -179,3 +201,11 @@ function getInputName(name: string): string {
|
||||
function setInput(name: string, value: string): void {
|
||||
process.env[getInputName(name)] = value;
|
||||
}
|
||||
|
||||
// Assert that process.stdout.write calls called only with the given arguments.
|
||||
function assertWriteCalls(calls: string[]): void {
|
||||
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
|
||||
for (let i = 0; i < calls.length; i++) {
|
||||
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
|
||||
}
|
||||
}
|
||||
|
23
__tests__/fixtures/event_tag_p1-v1.0.0.env
Normal file
23
__tests__/fixtures/event_tag_p1-v1.0.0.env
Normal file
@@ -0,0 +1,23 @@
|
||||
GITHUB_ACTION=crazy-maxghaction-dump-context
|
||||
GITHUB_ACTIONS=true
|
||||
GITHUB_ACTION_PATH=/home/runner/work/_actions/crazy-max/ghaction-dump-context/v1
|
||||
GITHUB_ACTOR=crazy-max
|
||||
GITHUB_API_URL=https://api.github.com
|
||||
GITHUB_BASE_REF=
|
||||
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_6ee180c2-b331-434a-a867-89534cbefd83
|
||||
GITHUB_EVENT_NAME=push
|
||||
#GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
|
||||
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
|
||||
GITHUB_HEAD_REF=
|
||||
GITHUB_JOB=event
|
||||
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_6ee180c2-b331-434a-a867-89534cbefd83
|
||||
GITHUB_REF=refs/tags/p1/v1.0.0
|
||||
GITHUB_REPOSITORY=crazy-max/test-docker-action
|
||||
GITHUB_REPOSITORY_OWNER=crazy-max
|
||||
GITHUB_RETENTION_DAYS=90
|
||||
GITHUB_RUN_ID=325968230
|
||||
GITHUB_RUN_NUMBER=4
|
||||
GITHUB_SERVER_URL=https://github.com
|
||||
GITHUB_SHA=90dd6032fac8bda1b6c4436a2e65de27961ed071
|
||||
GITHUB_WORKFLOW=event
|
||||
GITHUB_WORKSPACE=/home/runner/work/test-docker-action/test-docker-action
|
@@ -89,7 +89,8 @@ describe('null', () => {
|
||||
{
|
||||
images: ['user/app'],
|
||||
tags: [
|
||||
`type=sha`
|
||||
`type=sha`,
|
||||
`type=raw,{{branch}}`,
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -557,6 +558,65 @@ describe('push', () => {
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'push16',
|
||||
'event_push_defbranch.env',
|
||||
{
|
||||
images: ['user/app'],
|
||||
tags: [
|
||||
`type=match,enable=false,pattern=v(.*),group=1,value=v1.2.3`,
|
||||
`type=edge`
|
||||
],
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'edge',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'user/app:edge'
|
||||
],
|
||||
[
|
||||
"org.opencontainers.image.title=Hello-World",
|
||||
"org.opencontainers.image.description=This your first repo!",
|
||||
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.version=edge",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'push17',
|
||||
'event_push_defbranch.env',
|
||||
{
|
||||
images: ['user/app'],
|
||||
tags: [
|
||||
`type=raw,value=mytag-{{branch}}`,
|
||||
`type=raw,value=mytag-{{tag}}`
|
||||
],
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'mytag-master',
|
||||
partial: ['mytag-'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'user/app:mytag-master',
|
||||
'user/app:mytag-'
|
||||
],
|
||||
[
|
||||
"org.opencontainers.image.title=Hello-World",
|
||||
"org.opencontainers.image.description=This your first repo!",
|
||||
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.version=mytag-master",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
]
|
||||
])('given %p with %p event', tagsLabelsTest);
|
||||
});
|
||||
@@ -684,7 +744,7 @@ describe('tag', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d.\\d"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -715,7 +775,7 @@ describe('tag', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$",group=1`
|
||||
`type=match,"pattern=^v(\\d.\\d.\\d)$",group=1`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -746,7 +806,7 @@ describe('tag', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}-(alpha|beta).\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d.\\d-(alpha|beta).\\d+"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -777,7 +837,7 @@ describe('tag', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -808,24 +868,29 @@ describe('tag', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=/^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$/ig",group=1`,
|
||||
`type=match,"pattern=v(.*)-beta.(.*)",group=1`,
|
||||
`type=match,"pattern=v(.*)-beta.(.*)",group=2`,
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'v2.0.8-beta.67',
|
||||
partial: [],
|
||||
latest: false
|
||||
main: '2.0.8',
|
||||
partial: ['67'],
|
||||
latest: true
|
||||
} as Version,
|
||||
[
|
||||
'org/app:v2.0.8-beta.67',
|
||||
'ghcr.io/user/app:v2.0.8-beta.67'
|
||||
'org/app:2.0.8',
|
||||
'org/app:67',
|
||||
'org/app:latest',
|
||||
'ghcr.io/user/app:2.0.8',
|
||||
'ghcr.io/user/app:67',
|
||||
'ghcr.io/user/app:latest'
|
||||
],
|
||||
[
|
||||
"org.opencontainers.image.title=Hello-World",
|
||||
"org.opencontainers.image.description=This your first repo!",
|
||||
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.version=v2.0.8-beta.67",
|
||||
"org.opencontainers.image.version=2.0.8",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
@@ -837,24 +902,21 @@ describe('tag', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'sometag',
|
||||
main: undefined,
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:sometag',
|
||||
'ghcr.io/user/app:sometag'
|
||||
],
|
||||
[],
|
||||
[
|
||||
"org.opencontainers.image.title=Hello-World",
|
||||
"org.opencontainers.image.description=This your first repo!",
|
||||
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.version=sometag",
|
||||
"org.opencontainers.image.version=",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
@@ -1001,7 +1063,7 @@ describe('tag', () => {
|
||||
tags: [
|
||||
`type=raw,priority=2000,foo`,
|
||||
`type=semver,pattern={{version}}`,
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -1060,6 +1122,154 @@ describe('tag', () => {
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'tag17',
|
||||
'event_tag_p1-v1.0.0.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=/^v(\\d.\\d.\\d)$/ig",group=1`,
|
||||
`type=match,pattern=\\d.\\d.\\d`,
|
||||
`type=match,pattern=\\d.\\d`,
|
||||
`type=ref,event=pr`,
|
||||
`type=sha`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: '1.0.0',
|
||||
partial: ['1.0', 'sha-90dd603'],
|
||||
latest: true
|
||||
} as Version,
|
||||
[
|
||||
'org/app:1.0.0',
|
||||
'org/app:1.0',
|
||||
'org/app:sha-90dd603',
|
||||
'org/app:latest',
|
||||
'ghcr.io/user/app:1.0.0',
|
||||
'ghcr.io/user/app:1.0',
|
||||
'ghcr.io/user/app:sha-90dd603',
|
||||
'ghcr.io/user/app:latest'
|
||||
],
|
||||
[
|
||||
"org.opencontainers.image.title=Hello-World",
|
||||
"org.opencontainers.image.description=This your first repo!",
|
||||
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.version=1.0.0",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'tag18',
|
||||
'event_tag_p1-v1.0.0.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,pattern=p1-v(\\d.\\d.\\d),group=1`,
|
||||
`type=match,pattern=p1-v(\\d.\\d),group=1`,
|
||||
`type=match,pattern=p1-v(\\d.\\d),group=3`,
|
||||
`type=ref,event=pr`,
|
||||
`type=sha`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: '1.0.0',
|
||||
partial: ['1.0', 'sha-90dd603'],
|
||||
latest: true
|
||||
} as Version,
|
||||
[
|
||||
'org/app:1.0.0',
|
||||
'org/app:1.0',
|
||||
'org/app:sha-90dd603',
|
||||
'org/app:latest',
|
||||
'ghcr.io/user/app:1.0.0',
|
||||
'ghcr.io/user/app:1.0',
|
||||
'ghcr.io/user/app:sha-90dd603',
|
||||
'ghcr.io/user/app:latest'
|
||||
],
|
||||
[
|
||||
"org.opencontainers.image.title=Hello-World",
|
||||
"org.opencontainers.image.description=This your first repo!",
|
||||
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.version=1.0.0",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'tag19',
|
||||
'event_tag_p1-v1.0.0.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,pattern=p1-v(\\d.\\d.\\d),group=1`,
|
||||
`type=match,pattern=p1-v(\\d.\\d),group=1,suffix=`,
|
||||
`type=ref,event=pr`,
|
||||
`type=sha`
|
||||
],
|
||||
flavor: [
|
||||
`suffix=-dev`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: '1.0.0-dev',
|
||||
partial: ['1.0', 'sha-90dd603-dev'],
|
||||
latest: true
|
||||
} as Version,
|
||||
[
|
||||
'org/app:1.0.0-dev',
|
||||
'org/app:1.0',
|
||||
'org/app:sha-90dd603-dev',
|
||||
'org/app:latest',
|
||||
'ghcr.io/user/app:1.0.0-dev',
|
||||
'ghcr.io/user/app:1.0',
|
||||
'ghcr.io/user/app:sha-90dd603-dev',
|
||||
'ghcr.io/user/app:latest'
|
||||
],
|
||||
[
|
||||
"org.opencontainers.image.title=Hello-World",
|
||||
"org.opencontainers.image.description=This your first repo!",
|
||||
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.version=1.0.0-dev",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'tag20',
|
||||
'event_tag_v1.1.1.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=raw,{{tag}}-{{sha}}-foo`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'v1.1.1-90dd603-foo',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:v1.1.1-90dd603-foo',
|
||||
'ghcr.io/user/app:v1.1.1-90dd603-foo'
|
||||
],
|
||||
[
|
||||
"org.opencontainers.image.title=Hello-World",
|
||||
"org.opencontainers.image.description=This your first repo!",
|
||||
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.version=v1.1.1-90dd603-foo",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
]
|
||||
])('given %p with %p event', tagsLabelsTest);
|
||||
});
|
||||
@@ -1160,7 +1370,7 @@ describe('latest', () => {
|
||||
{
|
||||
images: ['user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d.\\d"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -1217,7 +1427,7 @@ describe('latest', () => {
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d.\\d"`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
@@ -1469,6 +1679,72 @@ describe('pr', () => {
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr05',
|
||||
'event_pull_request.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=ref,event=pr`
|
||||
],
|
||||
flavor: [
|
||||
`prefix=glo-`,
|
||||
`suffix=-bal`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'pr-2-bal',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:pr-2-bal',
|
||||
'ghcr.io/user/app:pr-2-bal'
|
||||
],
|
||||
[
|
||||
"org.opencontainers.image.title=Hello-World",
|
||||
"org.opencontainers.image.description=This your first repo!",
|
||||
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.version=pr-2-bal",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=1e9249f05bfc090e0688b8fb9c1b347586add504",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'pr06',
|
||||
'event_pull_request.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=ref,event=pr,prefix=`
|
||||
],
|
||||
flavor: [
|
||||
`prefix=glo-`,
|
||||
`suffix=-bal`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: '2-bal',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:2-bal',
|
||||
'ghcr.io/user/app:2-bal'
|
||||
],
|
||||
[
|
||||
"org.opencontainers.image.title=Hello-World",
|
||||
"org.opencontainers.image.description=This your first repo!",
|
||||
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.version=2-bal",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=1e9249f05bfc090e0688b8fb9c1b347586add504",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
]
|
||||
])('given %p with %p event', tagsLabelsTest);
|
||||
});
|
||||
|
||||
@@ -1649,6 +1925,39 @@ describe('schedule', () => {
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
[
|
||||
'schedule07',
|
||||
'event_schedule.env',
|
||||
{
|
||||
images: ['org/app', 'ghcr.io/user/app'],
|
||||
tags: [
|
||||
`type=schedule`,
|
||||
],
|
||||
flavor: [
|
||||
`prefix=glo-`,
|
||||
`suffix=-bal`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'glo-nightly-bal',
|
||||
partial: [],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'org/app:glo-nightly-bal',
|
||||
'ghcr.io/user/app:glo-nightly-bal'
|
||||
],
|
||||
[
|
||||
"org.opencontainers.image.title=Hello-World",
|
||||
"org.opencontainers.image.description=This your first repo!",
|
||||
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.version=glo-nightly-bal",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
])('given %p with %p event', tagsLabelsTest);
|
||||
});
|
||||
|
||||
@@ -2015,7 +2324,41 @@ describe('raw', () => {
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
'raw10',
|
||||
'event_push.env',
|
||||
{
|
||||
images: ['user/app'],
|
||||
tags: [
|
||||
`type=raw,foo`,
|
||||
`type=raw,bar,enable=false`,
|
||||
`type=raw,baz,enable=true`
|
||||
],
|
||||
flavor: [
|
||||
`latest=false`
|
||||
]
|
||||
} as Inputs,
|
||||
{
|
||||
main: 'foo',
|
||||
partial: ['baz'],
|
||||
latest: false
|
||||
} as Version,
|
||||
[
|
||||
'user/app:foo',
|
||||
'user/app:baz',
|
||||
],
|
||||
[
|
||||
"org.opencontainers.image.title=Hello-World",
|
||||
"org.opencontainers.image.description=This your first repo!",
|
||||
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
|
||||
"org.opencontainers.image.version=foo",
|
||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||
"org.opencontainers.image.licenses=MIT"
|
||||
]
|
||||
],
|
||||
])('given %p wth %p event', tagsLabelsTest);
|
||||
});
|
||||
|
||||
@@ -2039,7 +2382,7 @@ describe('bake', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
"target": {
|
||||
"ghaction-docker-meta": {
|
||||
"docker-metadata-action": {
|
||||
"tags": [
|
||||
"user/app:dev",
|
||||
"user/app:my",
|
||||
@@ -2076,7 +2419,7 @@ describe('bake', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
"target": {
|
||||
"ghaction-docker-meta": {
|
||||
"docker-metadata-action": {
|
||||
"tags": [
|
||||
"user/app:dev",
|
||||
"user/app:my",
|
||||
@@ -2109,11 +2452,12 @@ describe('bake', () => {
|
||||
`type=raw,my`,
|
||||
`type=raw,custom`,
|
||||
`type=raw,tags`
|
||||
]
|
||||
],
|
||||
bakeTarget: "meta"
|
||||
} as Inputs,
|
||||
{
|
||||
"target": {
|
||||
"ghaction-docker-meta": {
|
||||
"meta": {
|
||||
"tags": [
|
||||
"user/app:release1",
|
||||
"user/app:my",
|
||||
@@ -2156,7 +2500,7 @@ describe('bake', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
"target": {
|
||||
"ghaction-docker-meta": {
|
||||
"docker-metadata-action": {
|
||||
"tags": [
|
||||
"user/app:20200110",
|
||||
"user/app:my",
|
||||
@@ -2197,7 +2541,7 @@ describe('bake', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
"target": {
|
||||
"ghaction-docker-meta": {
|
||||
"docker-metadata-action": {
|
||||
"tags": [
|
||||
"org/app:1.1.1",
|
||||
"org/app:1.1",
|
||||
@@ -2245,7 +2589,7 @@ describe('bake', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
"target": {
|
||||
"ghaction-docker-meta": {
|
||||
"docker-metadata-action": {
|
||||
"tags": [
|
||||
"org/app:my",
|
||||
"org/app:custom",
|
||||
@@ -2286,7 +2630,7 @@ describe('bake', () => {
|
||||
} as Inputs,
|
||||
{
|
||||
"target": {
|
||||
"ghaction-docker-meta": {
|
||||
"docker-metadata-action": {
|
||||
"tags": [
|
||||
"org/app:v1.1.1",
|
||||
"org/app:latest"
|
||||
|
@@ -13,7 +13,7 @@ describe('transform', () => {
|
||||
`type=raw,foo`,
|
||||
`type=edge`,
|
||||
`type=semver,pattern={{version}}`,
|
||||
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}"`
|
||||
`type=match,"pattern=\\d.\\d.\\d",group=0`
|
||||
],
|
||||
[
|
||||
{
|
||||
@@ -21,8 +21,6 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Schedule],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "nightly"
|
||||
}
|
||||
},
|
||||
@@ -31,8 +29,6 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Semver],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "{{version}}",
|
||||
"value": ""
|
||||
}
|
||||
@@ -42,9 +38,7 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Match],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "\\d{1,3}.\\d{1,3}.\\d{1,3}",
|
||||
"pattern": "\\d.\\d.\\d",
|
||||
"group": "0",
|
||||
"value": ""
|
||||
}
|
||||
@@ -54,8 +48,6 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Edge],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"branch": ""
|
||||
}
|
||||
},
|
||||
@@ -64,8 +56,6 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Ref],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"event": RefEvent.Branch
|
||||
}
|
||||
},
|
||||
@@ -74,8 +64,6 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Ref],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"event": RefEvent.Tag
|
||||
}
|
||||
},
|
||||
@@ -85,7 +73,6 @@ describe('transform', () => {
|
||||
"priority": DefaultPriorities[Type.Ref],
|
||||
"enable": "true",
|
||||
"prefix": "pr-",
|
||||
"suffix": "",
|
||||
"event": RefEvent.PR
|
||||
}
|
||||
},
|
||||
@@ -94,8 +81,6 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Raw],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"value": "foo"
|
||||
}
|
||||
},
|
||||
@@ -104,8 +89,7 @@ describe('transform', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Sha],
|
||||
"enable": "true",
|
||||
"prefix": "sha-",
|
||||
"suffix": ""
|
||||
"prefix": "sha-"
|
||||
}
|
||||
}
|
||||
] as Tag[],
|
||||
@@ -135,8 +119,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Schedule],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "{{date 'YYYYMMDD'}}"
|
||||
}
|
||||
} as Tag,
|
||||
@@ -149,8 +131,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Semver],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "{{version}}",
|
||||
"value": ""
|
||||
}
|
||||
@@ -164,8 +144,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": "1",
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "{{version}}",
|
||||
"value": ""
|
||||
}
|
||||
@@ -179,8 +157,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": "1",
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "{{version}}",
|
||||
"value": "v1.0.0"
|
||||
}
|
||||
@@ -194,8 +170,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Match],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "v(.*)",
|
||||
"group": "1",
|
||||
"value": ""
|
||||
@@ -204,15 +178,13 @@ describe('parse', () => {
|
||||
false
|
||||
],
|
||||
[
|
||||
`type=match,enable=true,"pattern=^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$",group=1`,
|
||||
`type=match,enable=true,"pattern=^v(\\d.\\d.\\d)$",group=1`,
|
||||
{
|
||||
type: Type.Match,
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Match],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$",
|
||||
"pattern": "^v(\\d.\\d.\\d)$",
|
||||
"group": "1",
|
||||
"value": ""
|
||||
}
|
||||
@@ -226,8 +198,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": "700",
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "v(.*)",
|
||||
"group": "1",
|
||||
"value": ""
|
||||
@@ -242,8 +212,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Match],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"pattern": "v(.*)",
|
||||
"group": "1",
|
||||
"value": "v1.2.3"
|
||||
@@ -263,8 +231,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Edge],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"branch": ""
|
||||
}
|
||||
} as Tag,
|
||||
@@ -277,8 +243,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Edge],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"branch": "master"
|
||||
}
|
||||
} as Tag,
|
||||
@@ -291,8 +255,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Ref],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"event": RefEvent.Tag
|
||||
}
|
||||
} as Tag,
|
||||
@@ -305,8 +267,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Ref],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"event": RefEvent.Branch
|
||||
}
|
||||
} as Tag,
|
||||
@@ -320,7 +280,6 @@ describe('parse', () => {
|
||||
"priority": DefaultPriorities[Type.Ref],
|
||||
"enable": "true",
|
||||
"prefix": "pr-",
|
||||
"suffix": "",
|
||||
"event": RefEvent.PR
|
||||
}
|
||||
} as Tag,
|
||||
@@ -343,8 +302,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Raw],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"value": "acustomtag"
|
||||
}
|
||||
} as Tag,
|
||||
@@ -362,8 +319,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Raw],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"value": "acustomtag2"
|
||||
}
|
||||
} as Tag,
|
||||
@@ -376,8 +331,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Raw],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"value": "acustomtag4"
|
||||
}
|
||||
} as Tag,
|
||||
@@ -390,8 +343,6 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Raw],
|
||||
"enable": "false",
|
||||
"prefix": "",
|
||||
"suffix": "",
|
||||
"value": "acustomtag5"
|
||||
}
|
||||
} as Tag,
|
||||
@@ -404,8 +355,7 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Sha],
|
||||
"enable": "true",
|
||||
"prefix": "sha-",
|
||||
"suffix": ""
|
||||
"prefix": "sha-"
|
||||
}
|
||||
} as Tag,
|
||||
false
|
||||
@@ -417,8 +367,7 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Sha],
|
||||
"enable": "true",
|
||||
"prefix": "",
|
||||
"suffix": ""
|
||||
"prefix": ""
|
||||
}
|
||||
} as Tag,
|
||||
false
|
||||
@@ -430,8 +379,7 @@ describe('parse', () => {
|
||||
attrs: {
|
||||
"priority": DefaultPriorities[Type.Sha],
|
||||
"enable": "false",
|
||||
"prefix": "sha-",
|
||||
"suffix": ""
|
||||
"prefix": "sha-"
|
||||
}
|
||||
} as Tag,
|
||||
false
|
||||
|
@@ -1,10 +1,10 @@
|
||||
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
|
||||
name: 'Docker Meta'
|
||||
name: 'Docker Metadata action'
|
||||
description: "GitHub Action to extract metadata (tags, labels) for Docker"
|
||||
author: 'crazy-max'
|
||||
author: 'docker'
|
||||
branding:
|
||||
icon: 'anchor'
|
||||
color: 'blue'
|
||||
icon: 'layers'
|
||||
|
||||
inputs:
|
||||
images:
|
||||
@@ -25,6 +25,9 @@ inputs:
|
||||
sep-labels:
|
||||
description: 'Separator to use for labels output (default \n)'
|
||||
required: false
|
||||
bake-target:
|
||||
description: 'Bake target name (default docker-metadata-action)'
|
||||
required: false
|
||||
github-token:
|
||||
description: 'GitHub Token as provided by secrets'
|
||||
default: ${{ github.token }}
|
||||
|
@@ -1,51 +0,0 @@
|
||||
#syntax=docker/dockerfile:1.2
|
||||
|
||||
FROM node:12 AS deps
|
||||
WORKDIR /src
|
||||
COPY package.json yarn.lock ./
|
||||
RUN --mount=type=cache,target=/src/node_modules \
|
||||
yarn install
|
||||
|
||||
FROM scratch AS update-yarn
|
||||
COPY --from=deps /src/yarn.lock /
|
||||
|
||||
FROM deps AS validate-yarn
|
||||
COPY .git .git
|
||||
RUN status=$(git status --porcelain -- yarn.lock); if [ -n "$status" ]; then echo $status; exit 1; fi
|
||||
|
||||
FROM deps AS base
|
||||
COPY . .
|
||||
|
||||
FROM base AS build
|
||||
RUN --mount=type=cache,target=/src/node_modules \
|
||||
yarn build
|
||||
|
||||
FROM deps AS test
|
||||
ENV RUNNER_TEMP=/tmp/github_runner
|
||||
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
|
||||
COPY . .
|
||||
RUN --mount=type=cache,target=/src/node_modules \
|
||||
yarn run test
|
||||
|
||||
FROM scratch AS test-coverage
|
||||
COPY --from=test /src/coverage /coverage/
|
||||
|
||||
FROM base AS run-format
|
||||
RUN --mount=type=cache,target=/src/node_modules \
|
||||
yarn run format
|
||||
|
||||
FROM scratch AS format
|
||||
COPY --from=run-format /src/src/*.ts /src/
|
||||
|
||||
FROM base AS validate-format
|
||||
RUN --mount=type=cache,target=/src/node_modules \
|
||||
yarn run format-check
|
||||
|
||||
FROM scratch AS dist
|
||||
COPY --from=build /src/dist/ /dist/
|
||||
|
||||
FROM build AS validate-build
|
||||
RUN status=$(git status --porcelain -- dist); if [ -n "$status" ]; then echo $status; exit 1; fi
|
||||
|
||||
FROM base AS dev
|
||||
ENTRYPOINT ["bash"]
|
362
dist/index.js
generated
vendored
362
dist/index.js
generated
vendored
@@ -39,16 +39,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.asyncForEach = exports.getInputList = exports.getInputs = exports.tmpDir = void 0;
|
||||
exports.setOutput = exports.asyncForEach = exports.getInputList = exports.getInputs = exports.tmpDir = void 0;
|
||||
const sync_1 = __importDefault(__webpack_require__(8750));
|
||||
const core = __importStar(__webpack_require__(2186));
|
||||
const command_1 = __webpack_require__(7351);
|
||||
const fs = __importStar(__webpack_require__(5747));
|
||||
const os = __importStar(__webpack_require__(2087));
|
||||
const path = __importStar(__webpack_require__(5622));
|
||||
let _tmpDir;
|
||||
function tmpDir() {
|
||||
if (!_tmpDir) {
|
||||
_tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ghaction-docker-meta-')).split(path.sep).join(path.posix.sep);
|
||||
_tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-metadata-action-')).split(path.sep).join(path.posix.sep);
|
||||
}
|
||||
return _tmpDir;
|
||||
}
|
||||
@@ -61,6 +62,7 @@ function getInputs() {
|
||||
labels: getInputList('labels', true),
|
||||
sepTags: core.getInput('sep-tags') || `\n`,
|
||||
sepLabels: core.getInput('sep-labels') || `\n`,
|
||||
bakeTarget: core.getInput('bake-target') || `docker-metadata-action`,
|
||||
githubToken: core.getInput('github-token')
|
||||
};
|
||||
}
|
||||
@@ -94,17 +96,42 @@ exports.asyncForEach = (array, callback) => __awaiter(void 0, void 0, void 0, fu
|
||||
yield callback(array[index], index, array);
|
||||
}
|
||||
});
|
||||
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
||||
function setOutput(name, value) {
|
||||
command_1.issueCommand('set-output', { name }, value);
|
||||
}
|
||||
exports.setOutput = setOutput;
|
||||
//# sourceMappingURL=context.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3716:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Transform = void 0;
|
||||
const core = __importStar(__webpack_require__(2186));
|
||||
function Transform(inputs) {
|
||||
const flavor = {
|
||||
latest: 'auto',
|
||||
@@ -137,6 +164,11 @@ function Transform(inputs) {
|
||||
}
|
||||
}
|
||||
}
|
||||
core.startGroup(`Processing flavor input`);
|
||||
core.info(`latest=${flavor.latest}`);
|
||||
core.info(`prefix=${flavor.prefix}`);
|
||||
core.info(`suffix=${flavor.suffix}`);
|
||||
core.endGroup();
|
||||
return flavor;
|
||||
}
|
||||
exports.Transform = Transform;
|
||||
@@ -267,7 +299,7 @@ function run() {
|
||||
core.info(version.main || '');
|
||||
core.endGroup();
|
||||
}
|
||||
core.setOutput('version', version.main || '');
|
||||
context_1.setOutput('version', version.main || '');
|
||||
// Docker tags
|
||||
const tags = meta.getTags();
|
||||
if (tags.length == 0) {
|
||||
@@ -280,7 +312,7 @@ function run() {
|
||||
}
|
||||
core.endGroup();
|
||||
}
|
||||
core.setOutput('tags', tags.join(inputs.sepTags));
|
||||
context_1.setOutput('tags', tags.join(inputs.sepTags));
|
||||
// Docker labels
|
||||
const labels = meta.getLabels();
|
||||
core.startGroup(`Docker labels`);
|
||||
@@ -288,13 +320,13 @@ function run() {
|
||||
core.info(label);
|
||||
}
|
||||
core.endGroup();
|
||||
core.setOutput('labels', labels.join(inputs.sepLabels));
|
||||
context_1.setOutput('labels', labels.join(inputs.sepLabels));
|
||||
// Bake definition file
|
||||
const bakeFile = meta.getBakeFile();
|
||||
core.startGroup(`Bake definition file`);
|
||||
core.info(fs.readFileSync(bakeFile, 'utf8'));
|
||||
core.endGroup();
|
||||
core.setOutput('bake-file', bakeFile);
|
||||
context_1.setOutput('bake-file', bakeFile);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
@@ -361,6 +393,9 @@ class Meta {
|
||||
latest: undefined
|
||||
};
|
||||
for (const tag of this.tags) {
|
||||
if (!/true/i.test(tag.attrs['enable'])) {
|
||||
continue;
|
||||
}
|
||||
switch (tag.type) {
|
||||
case tcl.Type.Schedule: {
|
||||
version = this.procSchedule(version, tag);
|
||||
@@ -411,21 +446,12 @@ class Meta {
|
||||
return version;
|
||||
}
|
||||
const currentDate = this.date;
|
||||
const vraw = handlebars.compile(tag.attrs['pattern'])({
|
||||
const vraw = this.setValue(handlebars.compile(tag.attrs['pattern'])({
|
||||
date: function (format) {
|
||||
return moment_1.default(currentDate).utc().format(format);
|
||||
}
|
||||
});
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
}
|
||||
else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true';
|
||||
}
|
||||
return version;
|
||||
}), tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||
}
|
||||
procSemver(version, tag) {
|
||||
if (!/^refs\/tags\//.test(this.context.ref) && tag.attrs['value'].length == 0) {
|
||||
@@ -433,7 +459,7 @@ class Meta {
|
||||
}
|
||||
let vraw;
|
||||
if (tag.attrs['value'].length > 0) {
|
||||
vraw = tag.attrs['value'];
|
||||
vraw = this.setGlobalExp(tag.attrs['value']);
|
||||
}
|
||||
else {
|
||||
vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
||||
@@ -447,28 +473,13 @@ class Meta {
|
||||
includePrerelease: true
|
||||
});
|
||||
if (semver.prerelease(vraw)) {
|
||||
vraw = handlebars.compile('{{version}}')(sver);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
}
|
||||
else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
vraw = this.setValue(handlebars.compile('{{version}}')(sver), tag);
|
||||
}
|
||||
else {
|
||||
vraw = handlebars.compile(tag.attrs['pattern'])(sver);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
}
|
||||
else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
vraw = this.setValue(handlebars.compile(tag.attrs['pattern'])(sver), tag);
|
||||
latest = true;
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true';
|
||||
}
|
||||
return version;
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true');
|
||||
}
|
||||
procMatch(version, tag) {
|
||||
if (!/^refs\/tags\//.test(this.context.ref) && tag.attrs['value'].length == 0) {
|
||||
@@ -476,7 +487,7 @@ class Meta {
|
||||
}
|
||||
let vraw;
|
||||
if (tag.attrs['value'].length > 0) {
|
||||
vraw = tag.attrs['value'];
|
||||
vraw = this.setGlobalExp(tag.attrs['value']);
|
||||
}
|
||||
else {
|
||||
vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
||||
@@ -490,68 +501,37 @@ class Meta {
|
||||
else {
|
||||
tmatch = vraw.match(tag.attrs['pattern']);
|
||||
}
|
||||
if (tmatch) {
|
||||
vraw = tmatch[tag.attrs['group']];
|
||||
latest = true;
|
||||
if (!tmatch) {
|
||||
core.warning(`${tag.attrs['pattern']} does not match ${vraw}.`);
|
||||
return version;
|
||||
}
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
if (typeof tmatch[tag.attrs['group']] === 'undefined') {
|
||||
core.warning(`Group ${tag.attrs['group']} does not exist for ${tag.attrs['pattern']} pattern.`);
|
||||
return version;
|
||||
}
|
||||
else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true';
|
||||
}
|
||||
return version;
|
||||
vraw = this.setValue(tmatch[tag.attrs['group']], tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? true : this.flavor.latest == 'true');
|
||||
}
|
||||
procRefBranch(version, tag) {
|
||||
if (!/^refs\/heads\//.test(this.context.ref)) {
|
||||
return version;
|
||||
}
|
||||
const vraw = this.setFlavor(this.context.ref.replace(/^refs\/heads\//g, '').replace(/[^a-zA-Z0-9._-]+/g, '-'), tag);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
}
|
||||
else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true';
|
||||
}
|
||||
return version;
|
||||
const vraw = this.setValue(this.context.ref.replace(/^refs\/heads\//g, '').replace(/[^a-zA-Z0-9._-]+/g, '-'), tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||
}
|
||||
procRefTag(version, tag) {
|
||||
if (!/^refs\/tags\//.test(this.context.ref)) {
|
||||
return version;
|
||||
}
|
||||
const vraw = this.setFlavor(this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-'), tag);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
}
|
||||
else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? true : this.flavor.latest == 'true';
|
||||
}
|
||||
return version;
|
||||
const vraw = this.setValue(this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-'), tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? true : this.flavor.latest == 'true');
|
||||
}
|
||||
procRefPr(version, tag) {
|
||||
if (!/^refs\/pull\//.test(this.context.ref)) {
|
||||
return version;
|
||||
}
|
||||
const vraw = this.setFlavor(this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, ''), tag);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
}
|
||||
else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true';
|
||||
}
|
||||
return version;
|
||||
const vraw = this.setValue(this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, ''), tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||
}
|
||||
procEdge(version, tag) {
|
||||
if (!/^refs\/heads\//.test(this.context.ref)) {
|
||||
@@ -564,62 +544,70 @@ class Meta {
|
||||
if (tag.attrs['branch'] === val) {
|
||||
val = 'edge';
|
||||
}
|
||||
const vraw = this.setFlavor(val, tag);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
}
|
||||
else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true';
|
||||
}
|
||||
return version;
|
||||
const vraw = this.setValue(val, tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||
}
|
||||
procRaw(version, tag) {
|
||||
const vraw = this.setFlavor(tag.attrs['value'], tag);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
}
|
||||
else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true';
|
||||
}
|
||||
return version;
|
||||
const vraw = this.setValue(this.setGlobalExp(tag.attrs['value']), tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||
}
|
||||
procSha(version, tag) {
|
||||
if (!this.context.sha) {
|
||||
return version;
|
||||
}
|
||||
const vraw = this.setFlavor(this.context.sha.substr(0, 7), tag);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
const vraw = this.setValue(this.context.sha.substr(0, 7), tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||
}
|
||||
static setVersion(version, val, latest) {
|
||||
if (val.length == 0) {
|
||||
return version;
|
||||
}
|
||||
else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
if (version.main == undefined) {
|
||||
version.main = val;
|
||||
}
|
||||
else if (val !== version.main) {
|
||||
version.partial.push(val);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true';
|
||||
version.latest = latest;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
setFlavor(val, tag) {
|
||||
if (tag.attrs['prefix'].length > 0) {
|
||||
val = `${tag.attrs['prefix']}${val}`;
|
||||
setValue(val, tag) {
|
||||
if (tag.attrs.hasOwnProperty('prefix')) {
|
||||
val = `${this.setGlobalExp(tag.attrs['prefix'])}${val}`;
|
||||
}
|
||||
else if (this.flavor.prefix.length > 0) {
|
||||
val = `${this.flavor.prefix}${val}`;
|
||||
val = `${this.setGlobalExp(this.flavor.prefix)}${val}`;
|
||||
}
|
||||
if (tag.attrs['suffix'].length > 0) {
|
||||
val = `${val}${tag.attrs['suffix']}`;
|
||||
if (tag.attrs.hasOwnProperty('suffix')) {
|
||||
val = `${val}${this.setGlobalExp(tag.attrs['suffix'])}`;
|
||||
}
|
||||
else if (this.flavor.suffix.length > 0) {
|
||||
val = `${val}${this.flavor.suffix}`;
|
||||
val = `${val}${this.setGlobalExp(this.flavor.suffix)}`;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
setGlobalExp(val) {
|
||||
const ctx = this.context;
|
||||
return handlebars.compile(val)({
|
||||
branch: function () {
|
||||
if (!/^refs\/heads\//.test(ctx.ref)) {
|
||||
return '';
|
||||
}
|
||||
return ctx.ref.replace(/^refs\/heads\//g, '').replace(/[^a-zA-Z0-9._-]+/g, '-');
|
||||
},
|
||||
tag: function () {
|
||||
if (!/^refs\/tags\//.test(ctx.ref)) {
|
||||
return '';
|
||||
}
|
||||
return ctx.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
||||
},
|
||||
sha: function () {
|
||||
return ctx.sha.substr(0, 7);
|
||||
}
|
||||
});
|
||||
}
|
||||
getTags() {
|
||||
if (!this.version.main) {
|
||||
return [];
|
||||
@@ -661,10 +649,10 @@ class Meta {
|
||||
}
|
||||
jsonLabels[matches[1]] = matches[2];
|
||||
}
|
||||
const bakeFile = path.join(context_1.tmpDir(), 'ghaction-docker-meta-bake.json').split(path.sep).join(path.posix.sep);
|
||||
const bakeFile = path.join(context_1.tmpDir(), 'docker-metadata-action-bake.json').split(path.sep).join(path.posix.sep);
|
||||
fs.writeFileSync(bakeFile, JSON.stringify({
|
||||
target: {
|
||||
'ghaction-docker-meta': {
|
||||
[this.inputs.bakeTarget]: {
|
||||
tags: this.getTags(),
|
||||
labels: jsonLabels,
|
||||
args: {
|
||||
@@ -687,12 +675,32 @@ exports.Meta = Meta;
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Parse = exports.Transform = exports.DefaultPriorities = exports.RefEvent = exports.Type = void 0;
|
||||
exports.Parse = exports.Transform = exports.DefaultPriorities = exports.Tag = exports.RefEvent = exports.Type = void 0;
|
||||
const sync_1 = __importDefault(__webpack_require__(8750));
|
||||
const core = __importStar(__webpack_require__(2186));
|
||||
var Type;
|
||||
(function (Type) {
|
||||
Type["Schedule"] = "schedule";
|
||||
@@ -709,6 +717,19 @@ var RefEvent;
|
||||
RefEvent["Tag"] = "tag";
|
||||
RefEvent["PR"] = "pr";
|
||||
})(RefEvent = exports.RefEvent || (exports.RefEvent = {}));
|
||||
class Tag {
|
||||
constructor() {
|
||||
this.attrs = {};
|
||||
}
|
||||
toString() {
|
||||
const out = [`type=${this.type}`];
|
||||
for (let attr in this.attrs) {
|
||||
out.push(`${attr}=${this.attrs[attr]}`);
|
||||
}
|
||||
return out.join(',');
|
||||
}
|
||||
}
|
||||
exports.Tag = Tag;
|
||||
exports.DefaultPriorities = {
|
||||
[Type.Schedule]: '1000',
|
||||
[Type.Semver]: '900',
|
||||
@@ -732,7 +753,7 @@ function Transform(inputs) {
|
||||
for (const input of inputs) {
|
||||
tags.push(Parse(input));
|
||||
}
|
||||
return tags.sort((tag1, tag2) => {
|
||||
const sorted = tags.sort((tag1, tag2) => {
|
||||
if (Number(tag1.attrs['priority']) < Number(tag2.attrs['priority'])) {
|
||||
return 1;
|
||||
}
|
||||
@@ -741,6 +762,12 @@ function Transform(inputs) {
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
core.startGroup(`Processing tags input`);
|
||||
for (const tag of sorted) {
|
||||
core.info(tag.toString());
|
||||
}
|
||||
core.endGroup();
|
||||
return sorted;
|
||||
}
|
||||
exports.Transform = Transform;
|
||||
function Parse(s) {
|
||||
@@ -748,9 +775,7 @@ function Parse(s) {
|
||||
relaxColumnCount: true,
|
||||
skipLinesWithEmptyValues: true
|
||||
})[0];
|
||||
const tag = {
|
||||
attrs: {}
|
||||
};
|
||||
const tag = new Tag();
|
||||
for (const field of fields) {
|
||||
const parts = field.toString().split('=', 2);
|
||||
if (parts.length == 1) {
|
||||
@@ -847,12 +872,6 @@ function Parse(s) {
|
||||
if (!tag.attrs.hasOwnProperty('priority')) {
|
||||
tag.attrs['priority'] = exports.DefaultPriorities[tag.type];
|
||||
}
|
||||
if (!tag.attrs.hasOwnProperty('prefix')) {
|
||||
tag.attrs['prefix'] = '';
|
||||
}
|
||||
if (!tag.attrs.hasOwnProperty('suffix')) {
|
||||
tag.attrs['suffix'] = '';
|
||||
}
|
||||
if (!['true', 'false'].includes(tag.attrs['enable'])) {
|
||||
throw new Error(`Invalid value for enable attribute: ${tag.attrs['enable']}`);
|
||||
}
|
||||
@@ -1059,6 +1078,7 @@ exports.getInput = getInput;
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function setOutput(name, value) {
|
||||
process.stdout.write(os.EOL);
|
||||
command_1.issueCommand('set-output', { name }, value);
|
||||
}
|
||||
exports.setOutput = setOutput;
|
||||
@@ -5430,7 +5450,7 @@ class Parser extends Transform {
|
||||
], this.options, this.__context(), {
|
||||
record: record,
|
||||
})
|
||||
if(relax_column_count === true ||
|
||||
if(relax_column_count === true ||
|
||||
(relax_column_count_less === true && recordLength < this.state.expectedRecordLength) ||
|
||||
(relax_column_count_more === true && recordLength > this.state.expectedRecordLength) ){
|
||||
this.info.invalid_field_length++
|
||||
@@ -5460,7 +5480,7 @@ class Parser extends Transform {
|
||||
for(let i = 0, l = record.length; i < l; i++){
|
||||
if(columns[i] === undefined || columns[i].disabled) continue
|
||||
// Turn duplicate columns into an array
|
||||
if (columns_duplicates_to_array === true && obj[columns[i].name]) {
|
||||
if (columns_duplicates_to_array === true && obj[columns[i].name] !== undefined) {
|
||||
if (Array.isArray(obj[columns[i].name])) {
|
||||
obj[columns[i].name] = obj[columns[i].name].concat(record[i])
|
||||
} else {
|
||||
@@ -20871,22 +20891,30 @@ module.exports = (versions, range, options) => {
|
||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
const Range = __webpack_require__(9828)
|
||||
const { ANY } = __webpack_require__(1532)
|
||||
const Comparator = __webpack_require__(1532)
|
||||
const { ANY } = Comparator
|
||||
const satisfies = __webpack_require__(6055)
|
||||
const compare = __webpack_require__(4309)
|
||||
|
||||
// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
|
||||
// - Every simple range `r1, r2, ...` is a subset of some `R1, R2, ...`
|
||||
// - Every simple range `r1, r2, ...` is a null set, OR
|
||||
// - Every simple range `r1, r2, ...` which is not a null set is a subset of
|
||||
// some `R1, R2, ...`
|
||||
//
|
||||
// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
|
||||
// - If c is only the ANY comparator
|
||||
// - If C is only the ANY comparator, return true
|
||||
// - Else return false
|
||||
// - Else if in prerelease mode, return false
|
||||
// - else replace c with `[>=0.0.0]`
|
||||
// - If C is only the ANY comparator
|
||||
// - if in prerelease mode, return true
|
||||
// - else replace C with `[>=0.0.0]`
|
||||
// - Let EQ be the set of = comparators in c
|
||||
// - If EQ is more than one, return true (null set)
|
||||
// - Let GT be the highest > or >= comparator in c
|
||||
// - Let LT be the lowest < or <= comparator in c
|
||||
// - If GT and LT, and GT.semver > LT.semver, return true (null set)
|
||||
// - If any C is a = range, and GT or LT are set, return false
|
||||
// - If EQ
|
||||
// - If GT, and EQ does not satisfy GT, return true (null set)
|
||||
// - If LT, and EQ does not satisfy LT, return true (null set)
|
||||
@@ -20895,13 +20923,16 @@ const compare = __webpack_require__(4309)
|
||||
// - If GT
|
||||
// - If GT.semver is lower than any > or >= comp in C, return false
|
||||
// - If GT is >=, and GT.semver does not satisfy every C, return false
|
||||
// - If GT.semver has a prerelease, and not in prerelease mode
|
||||
// - If no C has a prerelease and the GT.semver tuple, return false
|
||||
// - If LT
|
||||
// - If LT.semver is greater than any < or <= comp in C, return false
|
||||
// - If LT is <=, and LT.semver does not satisfy every C, return false
|
||||
// - If any C is a = range, and GT or LT are set, return false
|
||||
// - If GT.semver has a prerelease, and not in prerelease mode
|
||||
// - If no C has a prerelease and the LT.semver tuple, return false
|
||||
// - Else return true
|
||||
|
||||
const subset = (sub, dom, options) => {
|
||||
const subset = (sub, dom, options = {}) => {
|
||||
if (sub === dom)
|
||||
return true
|
||||
|
||||
@@ -20930,8 +20961,21 @@ const simpleSubset = (sub, dom, options) => {
|
||||
if (sub === dom)
|
||||
return true
|
||||
|
||||
if (sub.length === 1 && sub[0].semver === ANY)
|
||||
return dom.length === 1 && dom[0].semver === ANY
|
||||
if (sub.length === 1 && sub[0].semver === ANY) {
|
||||
if (dom.length === 1 && dom[0].semver === ANY)
|
||||
return true
|
||||
else if (options.includePrerelease)
|
||||
sub = [ new Comparator('>=0.0.0-0') ]
|
||||
else
|
||||
sub = [ new Comparator('>=0.0.0') ]
|
||||
}
|
||||
|
||||
if (dom.length === 1 && dom[0].semver === ANY) {
|
||||
if (options.includePrerelease)
|
||||
return true
|
||||
else
|
||||
dom = [ new Comparator('>=0.0.0') ]
|
||||
}
|
||||
|
||||
const eqSet = new Set()
|
||||
let gt, lt
|
||||
@@ -20974,10 +21018,32 @@ const simpleSubset = (sub, dom, options) => {
|
||||
|
||||
let higher, lower
|
||||
let hasDomLT, hasDomGT
|
||||
// if the subset has a prerelease, we need a comparator in the superset
|
||||
// with the same tuple and a prerelease, or it's not a subset
|
||||
let needDomLTPre = lt &&
|
||||
!options.includePrerelease &&
|
||||
lt.semver.prerelease.length ? lt.semver : false
|
||||
let needDomGTPre = gt &&
|
||||
!options.includePrerelease &&
|
||||
gt.semver.prerelease.length ? gt.semver : false
|
||||
// exception: <1.2.3-0 is the same as <1.2.3
|
||||
if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&
|
||||
lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
|
||||
needDomLTPre = false
|
||||
}
|
||||
|
||||
for (const c of dom) {
|
||||
hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>='
|
||||
hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<='
|
||||
if (gt) {
|
||||
if (needDomGTPre) {
|
||||
if (c.semver.prerelease && c.semver.prerelease.length &&
|
||||
c.semver.major === needDomGTPre.major &&
|
||||
c.semver.minor === needDomGTPre.minor &&
|
||||
c.semver.patch === needDomGTPre.patch) {
|
||||
needDomGTPre = false
|
||||
}
|
||||
}
|
||||
if (c.operator === '>' || c.operator === '>=') {
|
||||
higher = higherGT(gt, c, options)
|
||||
if (higher === c && higher !== gt)
|
||||
@@ -20986,6 +21052,14 @@ const simpleSubset = (sub, dom, options) => {
|
||||
return false
|
||||
}
|
||||
if (lt) {
|
||||
if (needDomLTPre) {
|
||||
if (c.semver.prerelease && c.semver.prerelease.length &&
|
||||
c.semver.major === needDomLTPre.major &&
|
||||
c.semver.minor === needDomLTPre.minor &&
|
||||
c.semver.patch === needDomLTPre.patch) {
|
||||
needDomLTPre = false
|
||||
}
|
||||
}
|
||||
if (c.operator === '<' || c.operator === '<=') {
|
||||
lower = lowerLT(lt, c, options)
|
||||
if (lower === c && lower !== lt)
|
||||
@@ -21006,6 +21080,12 @@ const simpleSubset = (sub, dom, options) => {
|
||||
if (lt && hasDomGT && !gt && gtltComp !== 0)
|
||||
return false
|
||||
|
||||
// we needed a prerelease range in a specific tuple, but didn't get one
|
||||
// then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
|
||||
// because it includes prereleases in the 1.2.3 tuple
|
||||
if (needDomGTPre || needDomLTPre)
|
||||
return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
@@ -1,54 +1,67 @@
|
||||
variable "NODE_VERSION" {
|
||||
default = "12"
|
||||
}
|
||||
|
||||
target "node-version" {
|
||||
args = {
|
||||
NODE_VERSION = NODE_VERSION
|
||||
}
|
||||
}
|
||||
|
||||
group "default" {
|
||||
targets = ["build"]
|
||||
}
|
||||
|
||||
group "pre-checkin" {
|
||||
targets = ["update-yarn", "format", "build"]
|
||||
targets = ["vendor-update", "format", "build"]
|
||||
}
|
||||
|
||||
group "validate" {
|
||||
targets = ["validate-format", "validate-build", "validate-yarn"]
|
||||
}
|
||||
|
||||
target "dockerfile" {
|
||||
dockerfile = "dev.Dockerfile"
|
||||
}
|
||||
|
||||
target "update-yarn" {
|
||||
inherits = ["dockerfile"]
|
||||
target = "update-yarn"
|
||||
output = ["."]
|
||||
targets = ["format-validate", "build-validate", "vendor-validate"]
|
||||
}
|
||||
|
||||
target "build" {
|
||||
inherits = ["dockerfile"]
|
||||
target = "dist"
|
||||
inherits = ["node-version"]
|
||||
dockerfile = "./hack/build.Dockerfile"
|
||||
target = "build-update"
|
||||
output = ["."]
|
||||
}
|
||||
|
||||
target "test" {
|
||||
inherits = ["dockerfile"]
|
||||
target = "test-coverage"
|
||||
output = ["."]
|
||||
target "build-validate" {
|
||||
inherits = ["node-version"]
|
||||
dockerfile = "./hack/build.Dockerfile"
|
||||
target = "build-validate"
|
||||
}
|
||||
|
||||
target "format" {
|
||||
inherits = ["dockerfile"]
|
||||
target = "format"
|
||||
inherits = ["node-version"]
|
||||
dockerfile = "./hack/build.Dockerfile"
|
||||
target = "format-update"
|
||||
output = ["."]
|
||||
}
|
||||
|
||||
target "validate-format" {
|
||||
inherits = ["dockerfile"]
|
||||
target = "validate-format"
|
||||
target "format-validate" {
|
||||
inherits = ["node-version"]
|
||||
dockerfile = "./hack/build.Dockerfile"
|
||||
target = "format-validate"
|
||||
}
|
||||
|
||||
target "validate-build" {
|
||||
inherits = ["dockerfile"]
|
||||
target = "validate-build"
|
||||
target "vendor-update" {
|
||||
inherits = ["node-version"]
|
||||
dockerfile = "./hack/vendor.Dockerfile"
|
||||
target = "update"
|
||||
output = ["."]
|
||||
}
|
||||
|
||||
target "validate-yarn" {
|
||||
inherits = ["dockerfile"]
|
||||
target = "validate-yarn"
|
||||
target "vendor-validate" {
|
||||
inherits = ["node-version"]
|
||||
dockerfile = "./hack/vendor.Dockerfile"
|
||||
target = "validate"
|
||||
}
|
||||
|
||||
target "test" {
|
||||
inherits = ["node-version"]
|
||||
dockerfile = "./hack/test.Dockerfile"
|
||||
target = "test-coverage"
|
||||
output = ["./coverage"]
|
||||
}
|
||||
|
42
hack/build.Dockerfile
Normal file
42
hack/build.Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
# syntax=docker/dockerfile:1.2
|
||||
ARG NODE_VERSION
|
||||
|
||||
FROM node:${NODE_VERSION}-alpine AS base
|
||||
RUN apk add --no-cache cpio findutils git
|
||||
WORKDIR /src
|
||||
|
||||
FROM base AS deps
|
||||
RUN --mount=type=bind,target=.,rw \
|
||||
--mount=type=cache,target=/src/node_modules \
|
||||
yarn install
|
||||
|
||||
FROM deps AS build
|
||||
RUN --mount=type=bind,target=.,rw \
|
||||
--mount=type=cache,target=/src/node_modules \
|
||||
yarn run build && mkdir /out && cp -Rf dist /out/
|
||||
|
||||
FROM scratch AS build-update
|
||||
COPY --from=build /out /
|
||||
|
||||
FROM build AS build-validate
|
||||
RUN --mount=type=bind,target=.,rw \
|
||||
git add -A && cp -rf /out/* .; \
|
||||
if [ -n "$(git status --porcelain -- dist)" ]; then \
|
||||
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'; \
|
||||
git status --porcelain -- dist; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
FROM deps AS format
|
||||
RUN --mount=type=bind,target=.,rw \
|
||||
--mount=type=cache,target=/src/node_modules \
|
||||
yarn run format \
|
||||
&& mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out
|
||||
|
||||
FROM scratch AS format-update
|
||||
COPY --from=format /out /
|
||||
|
||||
FROM deps AS format-validate
|
||||
RUN --mount=type=bind,target=.,rw \
|
||||
--mount=type=cache,target=/src/node_modules \
|
||||
yarn run format-check \
|
21
hack/test.Dockerfile
Normal file
21
hack/test.Dockerfile
Normal file
@@ -0,0 +1,21 @@
|
||||
# syntax=docker/dockerfile:1.2
|
||||
ARG NODE_VERSION
|
||||
|
||||
FROM node:${NODE_VERSION}-alpine AS base
|
||||
RUN apk add --no-cache git
|
||||
WORKDIR /src
|
||||
|
||||
FROM base AS deps
|
||||
RUN --mount=type=bind,target=.,rw \
|
||||
--mount=type=cache,target=/src/node_modules \
|
||||
yarn install
|
||||
|
||||
FROM deps AS test
|
||||
ENV RUNNER_TEMP=/tmp/github_runner
|
||||
ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache
|
||||
RUN --mount=type=bind,target=.,rw \
|
||||
--mount=type=cache,target=/src/node_modules \
|
||||
yarn run test --coverageDirectory=/tmp/coverage
|
||||
|
||||
FROM scratch AS test-coverage
|
||||
COPY --from=test /tmp/coverage /
|
23
hack/vendor.Dockerfile
Normal file
23
hack/vendor.Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
||||
# syntax=docker/dockerfile:1.2
|
||||
ARG NODE_VERSION
|
||||
|
||||
FROM node:${NODE_VERSION}-alpine AS base
|
||||
RUN apk add --no-cache git
|
||||
WORKDIR /src
|
||||
|
||||
FROM base AS vendored
|
||||
RUN --mount=type=bind,target=.,rw \
|
||||
--mount=type=cache,target=/src/node_modules \
|
||||
yarn install && mkdir /out && cp yarn.lock /out
|
||||
|
||||
FROM scratch AS update
|
||||
COPY --from=vendored /out /
|
||||
|
||||
FROM vendored AS validate
|
||||
RUN --mount=type=bind,target=.,rw \
|
||||
git add -A && cp -rf /out/* .; \
|
||||
if [ -n "$(git status --porcelain -- yarn.lock)" ]; then \
|
||||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \
|
||||
git status --porcelain -- yarn.lock; \
|
||||
exit 1; \
|
||||
fi
|
22
package.json
22
package.json
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "docker-meta",
|
||||
"name": "docker-metadata-action",
|
||||
"description": "GitHub Action to extract metadata (tags, labels) for Docker",
|
||||
"main": "lib/main.js",
|
||||
"scripts": {
|
||||
@@ -11,24 +11,30 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/crazy-max/ghaction-docker-meta.git"
|
||||
"url": "git+https://github.com/docker/metadata-action.git"
|
||||
},
|
||||
"keywords": [
|
||||
"actions",
|
||||
"docker",
|
||||
"meta",
|
||||
"metadata",
|
||||
"tag",
|
||||
"label"
|
||||
],
|
||||
"author": "CrazyMax",
|
||||
"license": "MIT",
|
||||
"author": "Docker",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "CrazyMax",
|
||||
"url": "https://crazymax.dev"
|
||||
}
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/core": "^1.2.7",
|
||||
"@actions/github": "^4.0.0",
|
||||
"csv-parse": "^4.15.3",
|
||||
"csv-parse": "^4.15.4",
|
||||
"handlebars": "^4.7.7",
|
||||
"moment": "^2.29.1",
|
||||
"semver": "^7.3.4"
|
||||
"semver": "^7.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.0",
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import csvparse from 'csv-parse/lib/sync';
|
||||
import * as core from '@actions/core';
|
||||
import {issueCommand} from '@actions/core/lib/command';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
@@ -13,12 +14,13 @@ export interface Inputs {
|
||||
labels: string[];
|
||||
sepTags: string;
|
||||
sepLabels: string;
|
||||
bakeTarget: string;
|
||||
githubToken: string;
|
||||
}
|
||||
|
||||
export function tmpDir(): string {
|
||||
if (!_tmpDir) {
|
||||
_tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ghaction-docker-meta-')).split(path.sep).join(path.posix.sep);
|
||||
_tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-metadata-action-')).split(path.sep).join(path.posix.sep);
|
||||
}
|
||||
return _tmpDir;
|
||||
}
|
||||
@@ -31,6 +33,7 @@ export function getInputs(): Inputs {
|
||||
labels: getInputList('labels', true),
|
||||
sepTags: core.getInput('sep-tags') || `\n`,
|
||||
sepLabels: core.getInput('sep-labels') || `\n`,
|
||||
bakeTarget: core.getInput('bake-target') || `docker-metadata-action`,
|
||||
githubToken: core.getInput('github-token')
|
||||
};
|
||||
}
|
||||
@@ -66,3 +69,8 @@ export const asyncForEach = async (array, callback) => {
|
||||
await callback(array[index], index, array);
|
||||
}
|
||||
};
|
||||
|
||||
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
||||
export function setOutput(name: string, value: any): void {
|
||||
issueCommand('set-output', {name}, value);
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import * as core from '@actions/core';
|
||||
|
||||
export interface Flavor {
|
||||
latest: string;
|
||||
prefix: string;
|
||||
@@ -38,5 +40,11 @@ export function Transform(inputs: string[]): Flavor {
|
||||
}
|
||||
}
|
||||
|
||||
core.startGroup(`Processing flavor input`);
|
||||
core.info(`latest=${flavor.latest}`);
|
||||
core.info(`prefix=${flavor.prefix}`);
|
||||
core.info(`suffix=${flavor.suffix}`);
|
||||
core.endGroup();
|
||||
|
||||
return flavor;
|
||||
}
|
||||
|
10
src/main.ts
10
src/main.ts
@@ -1,5 +1,5 @@
|
||||
import * as fs from 'fs';
|
||||
import {getInputs, Inputs} from './context';
|
||||
import {getInputs, Inputs, setOutput} from './context';
|
||||
import * as github from './github';
|
||||
import {Meta, Version} from './meta';
|
||||
import * as core from '@actions/core';
|
||||
@@ -36,7 +36,7 @@ async function run() {
|
||||
core.info(version.main || '');
|
||||
core.endGroup();
|
||||
}
|
||||
core.setOutput('version', version.main || '');
|
||||
setOutput('version', version.main || '');
|
||||
|
||||
// Docker tags
|
||||
const tags: Array<string> = meta.getTags();
|
||||
@@ -49,7 +49,7 @@ async function run() {
|
||||
}
|
||||
core.endGroup();
|
||||
}
|
||||
core.setOutput('tags', tags.join(inputs.sepTags));
|
||||
setOutput('tags', tags.join(inputs.sepTags));
|
||||
|
||||
// Docker labels
|
||||
const labels: Array<string> = meta.getLabels();
|
||||
@@ -58,14 +58,14 @@ async function run() {
|
||||
core.info(label);
|
||||
}
|
||||
core.endGroup();
|
||||
core.setOutput('labels', labels.join(inputs.sepLabels));
|
||||
setOutput('labels', labels.join(inputs.sepLabels));
|
||||
|
||||
// Bake definition file
|
||||
const bakeFile: string = meta.getBakeFile();
|
||||
core.startGroup(`Bake definition file`);
|
||||
core.info(fs.readFileSync(bakeFile, 'utf8'));
|
||||
core.endGroup();
|
||||
core.setOutput('bake-file', bakeFile);
|
||||
setOutput('bake-file', bakeFile);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
196
src/meta.ts
196
src/meta.ts
@@ -44,6 +44,9 @@ export class Meta {
|
||||
};
|
||||
|
||||
for (const tag of this.tags) {
|
||||
if (!/true/i.test(tag.attrs['enable'])) {
|
||||
continue;
|
||||
}
|
||||
switch (tag.type) {
|
||||
case tcl.Type.Schedule: {
|
||||
version = this.procSchedule(version, tag);
|
||||
@@ -96,22 +99,16 @@ export class Meta {
|
||||
}
|
||||
|
||||
const currentDate = this.date;
|
||||
const vraw = handlebars.compile(tag.attrs['pattern'])({
|
||||
date: function (format) {
|
||||
return moment(currentDate).utc().format(format);
|
||||
}
|
||||
});
|
||||
const vraw = this.setValue(
|
||||
handlebars.compile(tag.attrs['pattern'])({
|
||||
date: function (format) {
|
||||
return moment(currentDate).utc().format(format);
|
||||
}
|
||||
}),
|
||||
tag
|
||||
);
|
||||
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
} else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true';
|
||||
}
|
||||
|
||||
return version;
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||
}
|
||||
|
||||
private procSemver(version: Version, tag: tcl.Tag): Version {
|
||||
@@ -121,7 +118,7 @@ export class Meta {
|
||||
|
||||
let vraw: string;
|
||||
if (tag.attrs['value'].length > 0) {
|
||||
vraw = tag.attrs['value'];
|
||||
vraw = this.setGlobalExp(tag.attrs['value']);
|
||||
} else {
|
||||
vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
||||
}
|
||||
@@ -135,26 +132,13 @@ export class Meta {
|
||||
includePrerelease: true
|
||||
});
|
||||
if (semver.prerelease(vraw)) {
|
||||
vraw = handlebars.compile('{{version}}')(sver);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
} else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
vraw = this.setValue(handlebars.compile('{{version}}')(sver), tag);
|
||||
} else {
|
||||
vraw = handlebars.compile(tag.attrs['pattern'])(sver);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
} else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
vraw = this.setValue(handlebars.compile(tag.attrs['pattern'])(sver), tag);
|
||||
latest = true;
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true';
|
||||
}
|
||||
|
||||
return version;
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true');
|
||||
}
|
||||
|
||||
private procMatch(version: Version, tag: tcl.Tag): Version {
|
||||
@@ -164,7 +148,7 @@ export class Meta {
|
||||
|
||||
let vraw: string;
|
||||
if (tag.attrs['value'].length > 0) {
|
||||
vraw = tag.attrs['value'];
|
||||
vraw = this.setGlobalExp(tag.attrs['value']);
|
||||
} else {
|
||||
vraw = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
||||
}
|
||||
@@ -177,75 +161,41 @@ export class Meta {
|
||||
} else {
|
||||
tmatch = vraw.match(tag.attrs['pattern']);
|
||||
}
|
||||
if (tmatch) {
|
||||
vraw = tmatch[tag.attrs['group']];
|
||||
latest = true;
|
||||
if (!tmatch) {
|
||||
core.warning(`${tag.attrs['pattern']} does not match ${vraw}.`);
|
||||
return version;
|
||||
}
|
||||
if (typeof tmatch[tag.attrs['group']] === 'undefined') {
|
||||
core.warning(`Group ${tag.attrs['group']} does not exist for ${tag.attrs['pattern']} pattern.`);
|
||||
return version;
|
||||
}
|
||||
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
} else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true';
|
||||
}
|
||||
|
||||
return version;
|
||||
vraw = this.setValue(tmatch[tag.attrs['group']], tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? true : this.flavor.latest == 'true');
|
||||
}
|
||||
|
||||
private procRefBranch(version: Version, tag: tcl.Tag): Version {
|
||||
if (!/^refs\/heads\//.test(this.context.ref)) {
|
||||
return version;
|
||||
}
|
||||
|
||||
const vraw = this.setFlavor(this.context.ref.replace(/^refs\/heads\//g, '').replace(/[^a-zA-Z0-9._-]+/g, '-'), tag);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
} else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true';
|
||||
}
|
||||
|
||||
return version;
|
||||
const vraw = this.setValue(this.context.ref.replace(/^refs\/heads\//g, '').replace(/[^a-zA-Z0-9._-]+/g, '-'), tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||
}
|
||||
|
||||
private procRefTag(version: Version, tag: tcl.Tag): Version {
|
||||
if (!/^refs\/tags\//.test(this.context.ref)) {
|
||||
return version;
|
||||
}
|
||||
|
||||
const vraw = this.setFlavor(this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-'), tag);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
} else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? true : this.flavor.latest == 'true';
|
||||
}
|
||||
|
||||
return version;
|
||||
const vraw = this.setValue(this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-'), tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? true : this.flavor.latest == 'true');
|
||||
}
|
||||
|
||||
private procRefPr(version: Version, tag: tcl.Tag): Version {
|
||||
if (!/^refs\/pull\//.test(this.context.ref)) {
|
||||
return version;
|
||||
}
|
||||
|
||||
const vraw = this.setFlavor(this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, ''), tag);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
} else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true';
|
||||
}
|
||||
|
||||
return version;
|
||||
const vraw = this.setValue(this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, ''), tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||
}
|
||||
|
||||
private procEdge(version: Version, tag: tcl.Tag): Version {
|
||||
@@ -261,65 +211,73 @@ export class Meta {
|
||||
val = 'edge';
|
||||
}
|
||||
|
||||
const vraw = this.setFlavor(val, tag);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
} else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true';
|
||||
}
|
||||
|
||||
return version;
|
||||
const vraw = this.setValue(val, tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||
}
|
||||
|
||||
private procRaw(version: Version, tag: tcl.Tag): Version {
|
||||
const vraw = this.setFlavor(tag.attrs['value'], tag);
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
} else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true';
|
||||
}
|
||||
|
||||
return version;
|
||||
const vraw = this.setValue(this.setGlobalExp(tag.attrs['value']), tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||
}
|
||||
|
||||
private procSha(version: Version, tag: tcl.Tag): Version {
|
||||
if (!this.context.sha) {
|
||||
return version;
|
||||
}
|
||||
const vraw = this.setValue(this.context.sha.substr(0, 7), tag);
|
||||
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
|
||||
}
|
||||
|
||||
const vraw = this.setFlavor(this.context.sha.substr(0, 7), tag);
|
||||
private static setVersion(version: Version, val: string, latest: boolean): Version {
|
||||
if (val.length == 0) {
|
||||
return version;
|
||||
}
|
||||
if (version.main == undefined) {
|
||||
version.main = vraw;
|
||||
} else if (vraw !== version.main) {
|
||||
version.partial.push(vraw);
|
||||
version.main = val;
|
||||
} else if (val !== version.main) {
|
||||
version.partial.push(val);
|
||||
}
|
||||
if (version.latest == undefined) {
|
||||
version.latest = this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true';
|
||||
version.latest = latest;
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
private setFlavor(val: string, tag: tcl.Tag): string {
|
||||
if (tag.attrs['prefix'].length > 0) {
|
||||
val = `${tag.attrs['prefix']}${val}`;
|
||||
private setValue(val: string, tag: tcl.Tag): string {
|
||||
if (tag.attrs.hasOwnProperty('prefix')) {
|
||||
val = `${this.setGlobalExp(tag.attrs['prefix'])}${val}`;
|
||||
} else if (this.flavor.prefix.length > 0) {
|
||||
val = `${this.flavor.prefix}${val}`;
|
||||
val = `${this.setGlobalExp(this.flavor.prefix)}${val}`;
|
||||
}
|
||||
if (tag.attrs['suffix'].length > 0) {
|
||||
val = `${val}${tag.attrs['suffix']}`;
|
||||
if (tag.attrs.hasOwnProperty('suffix')) {
|
||||
val = `${val}${this.setGlobalExp(tag.attrs['suffix'])}`;
|
||||
} else if (this.flavor.suffix.length > 0) {
|
||||
val = `${val}${this.flavor.suffix}`;
|
||||
val = `${val}${this.setGlobalExp(this.flavor.suffix)}`;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
private setGlobalExp(val): string {
|
||||
const ctx = this.context;
|
||||
return handlebars.compile(val)({
|
||||
branch: function () {
|
||||
if (!/^refs\/heads\//.test(ctx.ref)) {
|
||||
return '';
|
||||
}
|
||||
return ctx.ref.replace(/^refs\/heads\//g, '').replace(/[^a-zA-Z0-9._-]+/g, '-');
|
||||
},
|
||||
tag: function () {
|
||||
if (!/^refs\/tags\//.test(ctx.ref)) {
|
||||
return '';
|
||||
}
|
||||
return ctx.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
||||
},
|
||||
sha: function () {
|
||||
return ctx.sha.substr(0, 7);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public getTags(): Array<string> {
|
||||
if (!this.version.main) {
|
||||
return [];
|
||||
@@ -364,13 +322,13 @@ export class Meta {
|
||||
jsonLabels[matches[1]] = matches[2];
|
||||
}
|
||||
|
||||
const bakeFile = path.join(tmpDir(), 'ghaction-docker-meta-bake.json').split(path.sep).join(path.posix.sep);
|
||||
const bakeFile = path.join(tmpDir(), 'docker-metadata-action-bake.json').split(path.sep).join(path.posix.sep);
|
||||
fs.writeFileSync(
|
||||
bakeFile,
|
||||
JSON.stringify(
|
||||
{
|
||||
target: {
|
||||
'ghaction-docker-meta': {
|
||||
[this.inputs.bakeTarget]: {
|
||||
tags: this.getTags(),
|
||||
labels: jsonLabels,
|
||||
args: {
|
||||
|
41
src/tag.ts
41
src/tag.ts
@@ -1,4 +1,5 @@
|
||||
import csvparse from 'csv-parse/lib/sync';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
export enum Type {
|
||||
Schedule = 'schedule',
|
||||
@@ -16,9 +17,21 @@ export enum RefEvent {
|
||||
PR = 'pr'
|
||||
}
|
||||
|
||||
export interface Tag {
|
||||
type: Type;
|
||||
attrs: Record<string, string>;
|
||||
export class Tag {
|
||||
public type?: Type;
|
||||
public attrs: Record<string, string>;
|
||||
|
||||
constructor() {
|
||||
this.attrs = {};
|
||||
}
|
||||
|
||||
public toString(): string {
|
||||
const out: string[] = [`type=${this.type}`];
|
||||
for (let attr in this.attrs) {
|
||||
out.push(`${attr}=${this.attrs[attr]}`);
|
||||
}
|
||||
return out.join(',');
|
||||
}
|
||||
}
|
||||
|
||||
export const DefaultPriorities: Record<Type, string> = {
|
||||
@@ -42,10 +55,11 @@ export function Transform(inputs: string[]): Tag[] {
|
||||
`type=ref,event=${RefEvent.PR}`
|
||||
];
|
||||
}
|
||||
|
||||
for (const input of inputs) {
|
||||
tags.push(Parse(input));
|
||||
}
|
||||
return tags.sort((tag1, tag2) => {
|
||||
const sorted = tags.sort((tag1, tag2) => {
|
||||
if (Number(tag1.attrs['priority']) < Number(tag2.attrs['priority'])) {
|
||||
return 1;
|
||||
}
|
||||
@@ -54,6 +68,14 @@ export function Transform(inputs: string[]): Tag[] {
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
core.startGroup(`Processing tags input`);
|
||||
for (const tag of sorted) {
|
||||
core.info(tag.toString());
|
||||
}
|
||||
core.endGroup();
|
||||
|
||||
return sorted;
|
||||
}
|
||||
|
||||
export function Parse(s: string): Tag {
|
||||
@@ -62,10 +84,7 @@ export function Parse(s: string): Tag {
|
||||
skipLinesWithEmptyValues: true
|
||||
})[0];
|
||||
|
||||
const tag = {
|
||||
attrs: {}
|
||||
} as Tag;
|
||||
|
||||
const tag = new Tag();
|
||||
for (const field of fields) {
|
||||
const parts = field.toString().split('=', 2);
|
||||
if (parts.length == 1) {
|
||||
@@ -166,12 +185,6 @@ export function Parse(s: string): Tag {
|
||||
if (!tag.attrs.hasOwnProperty('priority')) {
|
||||
tag.attrs['priority'] = DefaultPriorities[tag.type];
|
||||
}
|
||||
if (!tag.attrs.hasOwnProperty('prefix')) {
|
||||
tag.attrs['prefix'] = '';
|
||||
}
|
||||
if (!tag.attrs.hasOwnProperty('suffix')) {
|
||||
tag.attrs['suffix'] = '';
|
||||
}
|
||||
if (!['true', 'false'].includes(tag.attrs['enable'])) {
|
||||
throw new Error(`Invalid value for enable attribute: ${tag.attrs['enable']}`);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
target "ghaction-docker-meta" {}
|
||||
target "docker-metadata-action" {}
|
||||
|
||||
group "default" {
|
||||
targets = ["db", "app"]
|
||||
@@ -14,7 +14,7 @@ target "db" {
|
||||
}
|
||||
|
||||
target "app" {
|
||||
inherits = ["ghaction-docker-meta"]
|
||||
inherits = ["docker-metadata-action"]
|
||||
context = "./test"
|
||||
dockerfile = "Dockerfile"
|
||||
args = {
|
||||
|
42
yarn.lock
42
yarn.lock
@@ -2,10 +2,10 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@actions/core@^1.2.6":
|
||||
version "1.2.6"
|
||||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09"
|
||||
integrity sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==
|
||||
"@actions/core@^1.2.7":
|
||||
version "1.2.7"
|
||||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.7.tgz#594f8c45b213f0146e4be7eda8ae5cf4e198e5ab"
|
||||
integrity sha512-kzLFD5BgEvq6ubcxdgPbRKGD2Qrgya/5j+wh4LZzqT915I0V3rED+MvjH6NXghbvk1MXknpNNQ3uKjXSEN00Ig==
|
||||
|
||||
"@actions/github@^4.0.0":
|
||||
version "4.0.0"
|
||||
@@ -1176,10 +1176,10 @@ cssstyle@^2.2.0:
|
||||
dependencies:
|
||||
cssom "~0.3.6"
|
||||
|
||||
csv-parse@^4.15.3:
|
||||
version "4.15.3"
|
||||
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-4.15.3.tgz#8a62759617a920c328cb31c351b05053b8f92b10"
|
||||
integrity sha512-jlTqDvLdHnYMSr08ynNfk4IAUSJgJjTKy2U5CQBSu4cN9vQOJonLVZP4Qo4gKKrIgIQ5dr07UwOJdi+lRqT12w==
|
||||
csv-parse@^4.15.4:
|
||||
version "4.15.4"
|
||||
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-4.15.4.tgz#ad1ec62aaf71a642982dfcb81f1848184d691db5"
|
||||
integrity sha512-OdBbFc0yZhOm17lSxqkirrHlFFVpKRT0wp4DAGoJelsP3LbGzV9LNr7XmM/lrr0uGkCtaqac9UhP8PDHXOAbMg==
|
||||
|
||||
dashdash@^1.12.0:
|
||||
version "1.14.1"
|
||||
@@ -1701,9 +1701,9 @@ has@^1.0.3:
|
||||
function-bind "^1.1.1"
|
||||
|
||||
hosted-git-info@^2.1.4:
|
||||
version "2.8.8"
|
||||
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
|
||||
integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==
|
||||
version "2.8.9"
|
||||
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
|
||||
integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==
|
||||
|
||||
html-encoding-sniffer@^2.0.1:
|
||||
version "2.0.1"
|
||||
@@ -2546,9 +2546,9 @@ lodash.sortby@^4.7.0:
|
||||
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
|
||||
|
||||
lodash@^4.17.19:
|
||||
version "4.17.20"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
|
||||
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
|
||||
version "4.17.21"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||
|
||||
lru-cache@^6.0.0:
|
||||
version "6.0.0"
|
||||
@@ -3175,10 +3175,10 @@ saxes@^5.0.0:
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
|
||||
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
|
||||
|
||||
semver@7.x, semver@^7.3.2, semver@^7.3.4:
|
||||
version "7.3.4"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97"
|
||||
integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==
|
||||
semver@7.x, semver@^7.3.2, semver@^7.3.5:
|
||||
version "7.3.5"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
|
||||
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
|
||||
dependencies:
|
||||
lru-cache "^6.0.0"
|
||||
|
||||
@@ -3818,9 +3818,9 @@ xmlchars@^2.2.0:
|
||||
integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==
|
||||
|
||||
y18n@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
|
||||
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4"
|
||||
integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==
|
||||
|
||||
yallist@^4.0.0:
|
||||
version "4.0.0"
|
||||
|
Reference in New Issue
Block a user