mirror of
https://github.com/hoverkraft-tech/compose-action.git
synced 2026-01-11 23:23:06 +08:00
feat: add support for compose flags (#7)
Add support for options (eg: --profile) to be passed to docker-compose.
This commit is contained in:
parent
65ecb06558
commit
ada3c6c7cd
5
.github/workflows/main.yml
vendored
5
.github/workflows/main.yml
vendored
@ -20,3 +20,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
compose-file: "./docker/docker-compose.yml"
|
compose-file: "./docker/docker-compose.yml"
|
||||||
down-flags: "--volumes"
|
down-flags: "--volumes"
|
||||||
|
- uses: ./
|
||||||
|
with:
|
||||||
|
compose-file: "./docker/docker-compose.yml"
|
||||||
|
compose-flags: "--profile profile-1"
|
||||||
|
down-flags: "--volumes"
|
||||||
|
|||||||
@ -5,6 +5,10 @@ inputs:
|
|||||||
description: "relative path to compose file"
|
description: "relative path to compose file"
|
||||||
required: false
|
required: false
|
||||||
default: "./docker-compose.yml"
|
default: "./docker-compose.yml"
|
||||||
|
compose-flags: # id of input
|
||||||
|
description: "additional options to pass to `docker-compose` command"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
down-flags: # id of input
|
down-flags: # id of input
|
||||||
description: "additional options to pass to `docker-compose down` command"
|
description: "additional options to pass to `docker-compose down` command"
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
@ -9,6 +9,8 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- test_volume:/test:Z
|
- test_volume:/test:Z
|
||||||
helloworld2:
|
helloworld2:
|
||||||
|
profiles: [profile-1]
|
||||||
image: hello-world
|
image: hello-world
|
||||||
helloworld3:
|
helloworld3:
|
||||||
|
profiles: [profile-2]
|
||||||
image: hello-world
|
image: hello-world
|
||||||
|
|||||||
11
main.js
11
main.js
@ -11,10 +11,13 @@ try {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const services = core.getMultilineInput("services", { required: false });
|
const services = core.getMultilineInput("services", { required: false });;
|
||||||
|
const options = {
|
||||||
const upFlagsString = core.getInput("up-flags");
|
config: composeFile,
|
||||||
const options = utils.getOptions(composeFile, upFlagsString);
|
log: true,
|
||||||
|
composeOptions: utils.parseFlags(core.getInput("compose-flags")),
|
||||||
|
commandOptions: utils.parseFlags(core.getInput("up-flags"))
|
||||||
|
};
|
||||||
|
|
||||||
const promise =
|
const promise =
|
||||||
services.length > 0
|
services.length > 0
|
||||||
|
|||||||
8
post.js
8
post.js
@ -10,8 +10,12 @@ try {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const downFlagsString = core.getInput("down-flags");
|
const options = {
|
||||||
const options = utils.getOptions(composeFile, downFlagsString);
|
config: composeFile,
|
||||||
|
log: true,
|
||||||
|
composeOptions: utils.parseFlags(core.getInput("compose-flags")),
|
||||||
|
commandOptions: utils.parseFlags(core.getInput("up-flags"))
|
||||||
|
};
|
||||||
|
|
||||||
compose.down(options).then(
|
compose.down(options).then(
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
7
utils.js
7
utils.js
@ -1,8 +1,7 @@
|
|||||||
module.exports.getOptions = (composeFile, flags) => {
|
module.exports.parseFlags = (flags) => {
|
||||||
const options = { config: composeFile, log: true };
|
|
||||||
if (flags != null && typeof flags == "string" && flags.length > 0) {
|
if (flags != null && typeof flags == "string" && flags.length > 0) {
|
||||||
options["commandOptions"] = flags.split(" ");
|
return flags.split(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
return options;
|
return [];
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user