mirror of
https://github.com/hoverkraft-tech/compose-action.git
synced 2026-01-11 23:23:06 +08:00
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.
This commit is contained in:
parent
5b5a1f9a95
commit
41bd5b12bd
1
.github/workflows/main.yml
vendored
1
.github/workflows/main.yml
vendored
@ -9,3 +9,4 @@ jobs:
|
|||||||
- uses: isbang/compose-action@v0.1
|
- uses: isbang/compose-action@v0.1
|
||||||
with:
|
with:
|
||||||
compose-file: './docker/docker-compose.yml'
|
compose-file: './docker/docker-compose.yml'
|
||||||
|
down-options: '--volumes'
|
||||||
|
|||||||
@ -8,6 +8,11 @@ This action runs your docker-compose file and clean up before action finished.
|
|||||||
|
|
||||||
**Optional** The name of the compose file. Default `"./docker-compose.yml"`.
|
**Optional** The name of the compose file. Default `"./docker-compose.yml"`.
|
||||||
|
|
||||||
|
### `down-options`
|
||||||
|
|
||||||
|
**Optional** Options to pass to the `docker-compose down` command during cleanup. Default is none. Primarily used to pass the `--volumes` flag if you want persistent volumes to be deleted as well during cleanup.
|
||||||
|
|
||||||
|
|
||||||
## Example usage
|
## Example usage
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
@ -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'
|
||||||
|
down-options: # id of input
|
||||||
|
description: 'additional options to pass to `docker-compose down` command'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'main.js'
|
main: 'main.js'
|
||||||
|
|||||||
3
post.js
3
post.js
@ -4,13 +4,14 @@ const fs = require('fs');
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const composeFile = core.getInput('compose-file');
|
const composeFile = core.getInput('compose-file');
|
||||||
|
const downOptions = core.getInput('down-options');
|
||||||
|
|
||||||
if (!fs.existsSync(composeFile)) {
|
if (!fs.existsSync(composeFile)) {
|
||||||
console.log(`${composeFile} not exists`);
|
console.log(`${composeFile} not exists`);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
compose.down({ config: composeFile, log: true })
|
compose.down({ config: composeFile, log: true, commandOptions: downOptions })
|
||||||
.then(
|
.then(
|
||||||
() => { console.log('compose removed')},
|
() => { console.log('compose removed')},
|
||||||
err => { core.setFailed(`compose down failed ${err}`)}
|
err => { core.setFailed(`compose down failed ${err}`)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user