Improve input naming
This commit is contained in:
parent
47dff6bd92
commit
aedc3e00d8
44
.github/workflows/ci.yaml
vendored
44
.github/workflows/ci.yaml
vendored
@ -14,56 +14,68 @@ jobs:
|
|||||||
image: registry:2
|
image: registry:2
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- 5000:5000
|
||||||
name: Test stacker-build action
|
name: Test stacker-build-push-action
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Run stacker-build with all build inputs
|
- name: Run stacker-build with all build inputs
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
stackerfile: 'test/stacker.yaml'
|
file: 'test/stacker.yaml'
|
||||||
substitutes: 'SUB1=VAR1 SUB2=VAR2 SUB3=VAR3'
|
build-args: |
|
||||||
|
SUB1=VAR1
|
||||||
|
SUB2=VAR2
|
||||||
|
SUB3=VAR3
|
||||||
layer-type: 'tar squashfs'
|
layer-type: 'tar squashfs'
|
||||||
|
|
||||||
- name: Run stacker-build with only substitutes
|
- name: Run stacker-build with only build-args
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
stackerfile: 'test/stacker.yaml'
|
file: 'test/stacker.yaml'
|
||||||
substitutes: 'SUB1=VAR1 SUB2=VAR2 SUB3=VAR3'
|
build-args: |
|
||||||
|
SUB1=VAR1
|
||||||
|
SUB2=VAR2
|
||||||
|
SUB3=VAR3
|
||||||
|
|
||||||
- name: Run stacker-build with only layer-type
|
- name: Run stacker-build with only layer-type
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
stackerfile: 'test/stacker_wo_subs.yaml'
|
file: 'test/stacker_wo_subs.yaml'
|
||||||
layer-type: 'tar squashfs'
|
layer-type: 'tar squashfs'
|
||||||
|
|
||||||
- name: Run stacker-build with only stackerfile
|
- name: Run stacker-build with only file input
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
stackerfile: 'test/stacker_wo_subs.yaml'
|
file: 'test/stacker_wo_subs.yaml'
|
||||||
|
|
||||||
- name: Run stacker-build with push and tags
|
- name: Run stacker-build with push and tags
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
stackerfile: 'test/stacker_wo_subs.yaml'
|
file: 'test/stacker_wo_subs.yaml'
|
||||||
tags: v1 latest
|
tags: v1 latest
|
||||||
url: docker://localhost:5000/name/app
|
url: docker://localhost:5000/name/app
|
||||||
skip-tls: true
|
skip-tls: true
|
||||||
|
|
||||||
- name: Run stacker-build with push, tags and substitutes
|
- name: Run stacker-build with push, tags and build-args
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
stackerfile: 'test/stacker.yaml'
|
file: 'test/stacker.yaml'
|
||||||
substitutes: 'SUB1=VAR1 SUB2=VAR2 SUB3=VAR3'
|
build-args: |
|
||||||
|
SUB1=VAR1
|
||||||
|
SUB2=VAR2
|
||||||
|
SUB3=VAR3
|
||||||
tags: v1 latest
|
tags: v1 latest
|
||||||
url: docker://localhost:5000/name/app
|
url: docker://localhost:5000/name/app
|
||||||
skip-tls: true
|
skip-tls: true
|
||||||
|
|
||||||
- name: Run stacker-build with push, tags, substitutes and layer-type
|
- name: Run stacker-build with push, tags, build-args and layer-type
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
stackerfile: 'test/stacker.yaml'
|
file: 'test/stacker.yaml'
|
||||||
substitutes: 'SUB1=VAR1 SUB2=VAR2 SUB3=VAR3'
|
build-args: |
|
||||||
|
SUB1=VAR1
|
||||||
|
SUB2=VAR2
|
||||||
|
SUB3=VAR3
|
||||||
tags: v1 latest
|
tags: v1 latest
|
||||||
url: docker://localhost:5000/name/app
|
url: docker://localhost:5000/name/app
|
||||||
layer-type: 'tar squashfs'
|
layer-type: 'tar squashfs'
|
||||||
|
46
README.md
46
README.md
@ -1,9 +1,9 @@
|
|||||||
# stacker-build-push-action
|
# stacker-build-push-action
|
||||||
# [![ci](https://github.com/project-stacker/stacker-build-push-action/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/project-stacker/stacker-build-push-action/actions)
|
# [![ci](https://github.com/project-stacker/stacker-build-push-action/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/project-stacker/stacker-build-push-action/actions)
|
||||||
|
|
||||||
stacker build action builds OCI container images via a declarative yaml format.
|
```stacker-build-push-action``` builds OCI container images via a declarative yaml format and publish them to OCI registries.
|
||||||
|
|
||||||
stacker only works on Linux
|
stacker only works on Linux!
|
||||||
|
|
||||||
For more information about stacker tool see: https://github.com/project-stacker/stacker
|
For more information about stacker tool see: https://github.com/project-stacker/stacker
|
||||||
|
|
||||||
@ -12,16 +12,17 @@ For more information about stacker tool see: https://github.com/project-stacker/
|
|||||||
|
|
||||||
<a id="dockerfile-build-inputs"></a>
|
<a id="dockerfile-build-inputs"></a>
|
||||||
|
|
||||||
| Input Name | Description | Default |
|
| Input Name | Type | Description | Default |
|
||||||
| ---------- | ----------- | ------- |
|
| ---------- | ---- |----------- | ------- |
|
||||||
| stackerfile | the yaml file to be built as an OCI image, example: [stacker.yaml](./test/stacker.yaml) | stacker.yaml
|
| file | string |the yaml file to be built as an OCI image, example: [stacker.yaml](./test/stacker.yaml) | stacker.yaml
|
||||||
| layer-type | output layer type (supported values: tar, squashfs), ca be both separated by whitespace | tar
|
| layer-type | list | output layer type (supported values: tar, squashfs), ca be both separated by whitespace | tar
|
||||||
| substitutes | variable substitution in stackerfile, see [stacker.yaml doc](https://github.com/project-stacker/stacker/blob/master/doc/stacker_yaml.md) | None
|
| build-args | list | the list of build-time arguments (subtitutes) separated by newline, see [stacker.yaml doc](https://github.com/project-stacker/stacker/blob/master/doc/stacker_yaml.md) | None
|
||||||
| url | remote OCI registry + repo name eg: docker://ghcr.io/project-stacker/ | None
|
| url | string | remote OCI registry + repo name eg: docker://ghcr.io/project-stacker/ | None
|
||||||
| tags | one or more tags to give the new image, separated by whitespace | None
|
| tags | list | one or more tags to give the new image, separated by whitespace | None
|
||||||
| username | used to login to registry | None
|
| username | string | used to login to registry | None
|
||||||
| password | used to login to registry | None
|
| password | string | used to login to registry | None
|
||||||
| skip-tls | used with unsecure (http) registries | false
|
| skip-tls | bool | used with unsecure (http) registries | false
|
||||||
|
| token | string |github token used to authenticate against a repository for Git context | ${{ github.token }}
|
||||||
|
|
||||||
|
|
||||||
Build only example:
|
Build only example:
|
||||||
@ -30,8 +31,11 @@ Build only example:
|
|||||||
- name: Run stacker-build
|
- name: Run stacker-build
|
||||||
uses: project-stacker/stacker-build-push-action@main
|
uses: project-stacker/stacker-build-push-action@main
|
||||||
with:
|
with:
|
||||||
stackerfile: 'test/stacker.yaml'
|
file: 'test/stacker.yaml'
|
||||||
substitutes: 'SUB1=VAR1 SUB2=VAR2 SUB3=VAR3'
|
build-args: |
|
||||||
|
SUB1=VAR1
|
||||||
|
SUB2=VAR2
|
||||||
|
SUB3=VAR3
|
||||||
layer-type: 'tar squashfs'
|
layer-type: 'tar squashfs'
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -47,8 +51,11 @@ Build and push example to ghcr.io:
|
|||||||
- name: Run stacker-build
|
- name: Run stacker-build
|
||||||
uses: project-stacker/stacker-build-push-action@main
|
uses: project-stacker/stacker-build-push-action@main
|
||||||
with:
|
with:
|
||||||
stackerfile: 'test/stacker.yaml'
|
file: 'test/stacker.yaml'
|
||||||
substitutes: 'SUB1=VAR1 SUB2=VAR2 SUB3=VAR3'
|
build-args: |
|
||||||
|
SUB1=VAR1
|
||||||
|
SUB2=VAR2
|
||||||
|
SUB3=VAR3
|
||||||
layer-type: 'tar squashfs'
|
layer-type: 'tar squashfs'
|
||||||
tags: ${{ github.event.release.tag_name }} latest
|
tags: ${{ github.event.release.tag_name }} latest
|
||||||
url: docker://ghcr.io/${{ github.repository }}
|
url: docker://ghcr.io/${{ github.repository }}
|
||||||
@ -66,8 +73,11 @@ Build and push example to localhost:
|
|||||||
- name: Run stacker-build
|
- name: Run stacker-build
|
||||||
uses: project-stacker/stacker-build-push-action@main
|
uses: project-stacker/stacker-build-push-action@main
|
||||||
with:
|
with:
|
||||||
stackerfile: 'test/stacker.yaml'
|
file: 'test/stacker.yaml'
|
||||||
substitutes: 'SUB1=VAR1 SUB2=VAR2 SUB3=VAR3'
|
build-args: |
|
||||||
|
SUB1=VAR1
|
||||||
|
SUB2=VAR2
|
||||||
|
SUB3=VAR3
|
||||||
layer-type: 'tar squashfs'
|
layer-type: 'tar squashfs'
|
||||||
url: docker://localhost:5000
|
url: docker://localhost:5000
|
||||||
skip-tls: true
|
skip-tls: true
|
||||||
|
10
action.yml
10
action.yml
@ -5,8 +5,8 @@ inputs:
|
|||||||
description: 'Which stacker version to use'
|
description: 'Which stacker version to use'
|
||||||
required: false
|
required: false
|
||||||
default: 'latest'
|
default: 'latest'
|
||||||
stackerfile: # id of input
|
file:
|
||||||
description: 'Which stackerfile to build'
|
description: 'Which stacker file to build'
|
||||||
required: true
|
required: true
|
||||||
default: 'stacker.yaml'
|
default: 'stacker.yaml'
|
||||||
layer-type:
|
layer-type:
|
||||||
@ -14,11 +14,11 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: "tar"
|
default: "tar"
|
||||||
token:
|
token:
|
||||||
description: 'Used to pull stacker release binaries'
|
description: 'GitHub Token used to authenticate against a repository for Git context'
|
||||||
required: false
|
required: false
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
substitutes:
|
build-args:
|
||||||
description: 'The list of subtitutes to make in stacker file separated by whitespace, eg: ONE=1 TWO=2 THREE=3'
|
description: 'The list of build-time arguments separated by whitespace, eg: ONE=1 TWO=2 THREE=3'
|
||||||
required: false
|
required: false
|
||||||
tags:
|
tags:
|
||||||
description: 'Tags used when pushing to remote OCI registry, separated by whitespace'
|
description: 'Tags used when pushing to remote OCI registry, separated by whitespace'
|
||||||
|
50
dist/index.js
vendored
50
dist/index.js
vendored
@ -23841,6 +23841,31 @@ function makeAvailableInPath(download, version) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
;// CONCATENATED MODULE: ./src/utils.ts
|
||||||
|
|
||||||
|
function splitByNewline(s) {
|
||||||
|
return s.split(/\r?\n/);
|
||||||
|
}
|
||||||
|
function getInputList(name) {
|
||||||
|
const items = core.getInput(name);
|
||||||
|
if (!items) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const splitItems = splitByNewline(items);
|
||||||
|
return splitItems
|
||||||
|
.reduce((acc, line) => acc.concat(line).map((item) => item.trim()), []);
|
||||||
|
}
|
||||||
|
function getSpaceSeparatedInput(name) {
|
||||||
|
const items = core.getInput(name);
|
||||||
|
if (items.length === 0) {
|
||||||
|
core.debug("empty");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const splitItems = items.trim().split(/\s+/);
|
||||||
|
return splitItems
|
||||||
|
.reduce((acc, line) => acc.concat(line).map((item) => item.trim()), []);
|
||||||
|
}
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ./src/index.ts
|
;// CONCATENATED MODULE: ./src/index.ts
|
||||||
var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
@ -23856,6 +23881,7 @@ var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argu
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const stackerBin = "stacker";
|
const stackerBin = "stacker";
|
||||||
const stackerOrg = "project-stacker";
|
const stackerOrg = "project-stacker";
|
||||||
const stackerRepo = "stacker";
|
const stackerRepo = "stacker";
|
||||||
@ -23879,29 +23905,17 @@ function run() {
|
|||||||
const stackerPath = yield io.which("stacker", true);
|
const stackerPath = yield io.which("stacker", true);
|
||||||
const cli = new StackerCLI(stackerPath);
|
const cli = new StackerCLI(stackerPath);
|
||||||
yield cli.execute(["--version"], { group: true });
|
yield cli.execute(["--version"], { group: true });
|
||||||
const stackerfile = core.getInput("stackerfile");
|
const stackerfile = core.getInput("file");
|
||||||
var substitutesList = [];
|
const substitutes = getInputList("build-args");
|
||||||
const substitutes = core.getInput("substitutes");
|
const layerTypes = getSpaceSeparatedInput("layer-type");
|
||||||
if (substitutes != "") {
|
yield cli.build(stackerfile, layerTypes, substitutes);
|
||||||
substitutesList = substitutes.trim().split(/\s+/);
|
const tags = getSpaceSeparatedInput("tags");
|
||||||
}
|
|
||||||
var layerTypeList = [];
|
|
||||||
const layerType = core.getInput("layer-type");
|
|
||||||
if (layerType != "") {
|
|
||||||
layerTypeList = layerType.trim().split(/\s+/);
|
|
||||||
}
|
|
||||||
yield cli.build(stackerfile, layerTypeList, substitutesList);
|
|
||||||
var tagsList = [];
|
|
||||||
const tags = core.getInput("tags");
|
|
||||||
if (tags != "") {
|
|
||||||
tagsList = tags.trim().split(/\s+/);
|
|
||||||
}
|
|
||||||
const registryURL = core.getInput("url");
|
const registryURL = core.getInput("url");
|
||||||
const username = core.getInput("username");
|
const username = core.getInput("username");
|
||||||
const password = core.getInput("password");
|
const password = core.getInput("password");
|
||||||
const skipTLS = core.getInput("skip-tls") === "true";
|
const skipTLS = core.getInput("skip-tls") === "true";
|
||||||
if (registryURL) {
|
if (registryURL) {
|
||||||
yield cli.publish(stackerfile, layerTypeList, substitutesList, registryURL, tagsList, username, password, skipTLS);
|
yield cli.publish(stackerfile, layerTypes, substitutes, registryURL, tags, username, password, skipTLS);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
31
src/index.ts
31
src/index.ts
@ -4,6 +4,7 @@ import * as tc from "@actions/tool-cache";
|
|||||||
|
|
||||||
import { StackerCLI } from "./stacker";
|
import { StackerCLI } from "./stacker";
|
||||||
import * as installer from "./installer";
|
import * as installer from "./installer";
|
||||||
|
import * as utils from "./utils";
|
||||||
|
|
||||||
export const stackerBin = "stacker";
|
export const stackerBin = "stacker";
|
||||||
export const stackerOrg = "project-stacker";
|
export const stackerOrg = "project-stacker";
|
||||||
@ -37,28 +38,18 @@ export async function run(): Promise<void> {
|
|||||||
await cli.execute(["--version"], { group: true });
|
await cli.execute(["--version"], { group: true });
|
||||||
|
|
||||||
// get stacker file path from input
|
// get stacker file path from input
|
||||||
const stackerfile = core.getInput("stackerfile");
|
const stackerfile = core.getInput("file");
|
||||||
|
|
||||||
// get substitutes from input
|
// get build-args from input
|
||||||
var substitutesList: string[] = [];
|
const substitutes = utils.getInputList("build-args");
|
||||||
const substitutes = core.getInput("substitutes");
|
|
||||||
if (substitutes != "") {
|
|
||||||
substitutesList = substitutes.trim().split(/\s+/);
|
|
||||||
}
|
|
||||||
|
|
||||||
var layerTypeList: string[] = [];
|
// get layer-type from input
|
||||||
const layerType = core.getInput("layer-type");
|
const layerTypes = utils.getSpaceSeparatedInput("layer-type");
|
||||||
if (layerType != "") {
|
|
||||||
layerTypeList = layerType.trim().split(/\s+/);
|
|
||||||
}
|
|
||||||
|
|
||||||
await cli.build(stackerfile, layerTypeList, substitutesList);
|
await cli.build(stackerfile, layerTypes, substitutes);
|
||||||
|
|
||||||
var tagsList: string[] = [];
|
// get tags from input
|
||||||
const tags = core.getInput("tags");
|
const tags = utils.getSpaceSeparatedInput("tags");
|
||||||
if (tags != "") {
|
|
||||||
tagsList = tags.trim().split(/\s+/);
|
|
||||||
}
|
|
||||||
|
|
||||||
const registryURL = core.getInput("url");
|
const registryURL = core.getInput("url");
|
||||||
const username = core.getInput("username");
|
const username = core.getInput("username");
|
||||||
@ -66,8 +57,8 @@ export async function run(): Promise<void> {
|
|||||||
const skipTLS = core.getInput("skip-tls") === "true";
|
const skipTLS = core.getInput("skip-tls") === "true";
|
||||||
|
|
||||||
if (registryURL) {
|
if (registryURL) {
|
||||||
await cli.publish(stackerfile, layerTypeList, substitutesList,
|
await cli.publish(stackerfile, layerTypes, substitutes,
|
||||||
registryURL, tagsList, username, password, skipTLS);
|
registryURL, tags, username, password, skipTLS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
src/utils.ts
Normal file
33
src/utils.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import * as core from "@actions/core";
|
||||||
|
|
||||||
|
export function splitByNewline(s: string): string[] {
|
||||||
|
return s.split(/\r?\n/);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getInputList(name: string): string[] {
|
||||||
|
const items = core.getInput(name);
|
||||||
|
if (!items) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const splitItems = splitByNewline(items);
|
||||||
|
return splitItems
|
||||||
|
.reduce<string[]>(
|
||||||
|
(acc, line) => acc.concat(line).map((item) => item.trim()),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSpaceSeparatedInput(name: string): string[] {
|
||||||
|
const items = core.getInput(name);
|
||||||
|
if (items.length === 0) {
|
||||||
|
core.debug("empty");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
const splitItems = items.trim().split(/\s+/);
|
||||||
|
|
||||||
|
return splitItems
|
||||||
|
.reduce<string[]>(
|
||||||
|
(acc, line) => acc.concat(line).map((item) => item.trim()),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user