Repository: crazy-max/ghaction-docker-meta
Pull request #69 (2021-04-29 22:49:37)

Add bake-target input


Patch:
diff --git a/README.md b/README.md
index 6395410..d53c052 100644
--- a/README.md
+++ b/README.md
@@ -271,6 +271,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 `ghaction-docker-meta`) |
 
 ### outputs
 
diff --git a/action.yml b/action.yml
index d7fdf12..c4212e6 100644
--- a/action.yml
+++ b/action.yml
@@ -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 ghaction-docker-meta)'
+    required: false
   github-token:
     description: 'GitHub Token as provided by secrets'
     default: ${{ github.token }}
diff --git a/dist/index.js b/dist/index.js
index 9940592..ed5b6d5 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -62,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') || `ghaction-docker-meta`,
         githubToken: core.getInput('github-token')
     };
 }
@@ -698,7 +699,7 @@ class Meta {
         const bakeFile = path.join(context_1.tmpDir(), 'ghaction-docker-meta-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: {
diff --git a/src/context.ts b/src/context.ts
index 5306b81..527b4ad 100644
--- a/src/context.ts
+++ b/src/context.ts
@@ -14,6 +14,7 @@ export interface Inputs {
   labels: string[];
   sepTags: string;
   sepLabels: string;
+  bakeTarget: string;
   githubToken: string;
 }
 
@@ -32,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') || `ghaction-docker-meta`,
     githubToken: core.getInput('github-token')
   };
 }
diff --git a/src/meta.ts b/src/meta.ts
index 2e5b978..e16ec90 100644
--- a/src/meta.ts
+++ b/src/meta.ts
@@ -378,7 +378,7 @@ export class Meta {
       JSON.stringify(
         {
           target: {
-            'ghaction-docker-meta': {
+            [this.inputs.bakeTarget]: {
               tags: this.getTags(),
               labels: jsonLabels,
               args: {


Test patch:
diff --git a/__tests__/meta.test.ts b/__tests__/meta.test.ts
index e165297..e815847 100644
--- a/__tests__/meta.test.ts
+++ b/__tests__/meta.test.ts
@@ -2392,11 +2392,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",