compose-action/post.js
Thorrak 41bd5b12bd Add down-options configuration option
This new, optional configuration parameter allows for the specification of flags to be passed to the `docker-compose down` command. This is primarily intended to be used for passing the `--volumes` flag whith instructs docker-compose to also delete persistent volumes.
2021-04-23 09:54:17 -04:00

22 lines
580 B
JavaScript

const core = require('@actions/core');
const compose = require('docker-compose');
const fs = require('fs');
try {
const composeFile = core.getInput('compose-file');
const downOptions = core.getInput('down-options');
if (!fs.existsSync(composeFile)) {
console.log(`${composeFile} not exists`);
return
}
compose.down({ config: composeFile, log: true, commandOptions: downOptions })
.then(
() => { console.log('compose removed')},
err => { core.setFailed(`compose down failed ${err}`)}
);
} catch (error) {
core.setFailed(error.message);
}