https://github.com/hoverkraft-tech/compose-action
This action runs your docker-compose file and clean up before action finished
https://github.com/hoverkraft-tech/compose-action
docker-compose github-actions
Last synced: 25 days ago
JSON representation
This action runs your docker-compose file and clean up before action finished
- Host: GitHub
- URL: https://github.com/hoverkraft-tech/compose-action
- Owner: hoverkraft-tech
- License: mit
- Created: 2020-11-02T05:20:19.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-28T06:06:47.000Z (about 1 month ago)
- Last Synced: 2025-03-31T07:01:41.068Z (29 days ago)
- Topics: docker-compose, github-actions
- Language: TypeScript
- Homepage: https://github.com/marketplace/actions/docker-compose-action
- Size: 14.3 MB
- Stars: 169
- Watchers: 1
- Forks: 25
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-ccamel - hoverkraft-tech/compose-action - This action runs your docker-compose file and clean up before action finished (TypeScript)
README
This action runs your compose file(s) and clean up before action finished
## Usage
### Action
The action will run `docker compose up` to start the services defined in the given compose file(s).
The compose file(s) can be specified using the `compose-file` input.
Some extra options can be passed to the `docker compose up` command using the `up-flags` input.### Post hook
On post hook, the action will run `docker compose down` to clean up the services.
In [debug mode](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/troubleshooting-workflows/enabling-debug-logging), the logs of the running services are printed before the cleanup.Some extra options can be passed to the `docker compose down` command using the `down-flags` input.
```yaml
- uses: hoverkraft-tech/[email protected]
with:
# Description: Additional options to pass to `docker` command.
#
docker-flags: ""# Description: Path to compose file(s). It can be a list of files. It can be
# absolute or relative to the current working directory (cwd).
#
# Default: ./docker-compose.yml
compose-file: ""# Description: Services to perform docker compose up.
#
services: ""# Description: Additional options to pass to `docker compose up` command.
#
# Default:
up-flags: ""# Description: Additional options to pass to `docker compose down` command.
#
# Default:
down-flags: ""# Description: Additional options to pass to `docker compose` command.
#
# Default:
compose-flags: ""# Description: Current working directory
#
# Default: ${{ github.workspace }}
cwd: ""# Description: Compose version to use. If null (default), it will use the current
# installed version. If "latest", it will install the latest version.
#
compose-version: ""# Description: The GitHub token used to create an authenticated client (to fetch
# the latest version of docker compose).
#
# Default: ${{ github.token }}
github-token: ""
```## Inputs
| **Input** | **Description** | **Default** | **Required** |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ | ------------ |
|docker-flags
| Additional options to pass todocker
command. | | **false** |
|compose-file
| Path to compose file(s). It can be a list of files. It can be absolute or relative to the current working directory (cwd). |./docker-compose.yml
| **false** |
|services
| Services to perform docker compose up. | | **false** |
|up-flags
| Additional options to pass todocker compose up
command. | | **false** |
|down-flags
| Additional options to pass todocker compose down
command. | | **false** |
|compose-flags
| Additional options to pass todocker compose
command. | | **false** |
|cwd
| Current working directory |${{ github.workspace }}
| **false** |
|compose-version
| Compose version to use.
If null (default), it will use the current installed version.
If "latest", it will install the latest version. | | **false** |
|github-token
| The GitHub token used to create an authenticated client (to fetch the latest version of docker compose). |${{ github.token }}
| **false** |## Examples
### Example using in a full workflow
```yaml
name: Docker Compose Actionon: [push]
jobs:
build:
runs-on: ubuntu-lateststeps:
- uses: actions/[email protected]- name: Run docker compose
uses: hoverkraft-tech/[email protected]
with:
compose-file: "./docker/docker-compose.yml"- name: Execute tests in the running services
run: |
docker compose exec test-app pytest
```### Example Using environment variables
```yaml
steps:
- uses: actions/[email protected]
- uses: hoverkraft-tech/[email protected]
with:
compose-file: "./docker/docker-compose.yml"
env:
CUSTOM_VARIABLE: "test"
```### Example using `services`
Perform `docker compose up` to some given service instead of all of them
```yaml
steps:
# need checkout before using compose-action
- uses: actions/checkout@v3
- uses: hoverkraft-tech/[email protected]
with:
compose-file: "./docker/docker-compose.yml"
services: |
helloworld2
helloworld3
```### Example using `up-flags`
Specify flags to pass to the `docker compose up`. Default is none. Can be used
to pass the `--build` flag, for example, if you want persistent volumes to be
deleted as well during cleanup. A full list of flags can be found in the
[docker compose up documentation](https://docs.docker.com/compose/reference/up/).### Example using `down-flags`
Specify flags to pass to the `docker compose down` command during cleanup.
Default is none. Can be used to pass the `--volumes` flag, for example, if you
want persistent volumes to be deleted as well during cleanup. A full list of
flags can be found in the
[docker compose down documentation](https://docs.docker.com/compose/reference/down/).### Example using `compose-flags`
Specify flags to pass to the `docker compose` command. Default is none. A full
list of flags can be found in the
[docker compose documentation](https://docs.docker.com/compose/reference/#command-options-overview-and-help).```yaml
steps:
# need checkout before using compose-action
- uses: actions/checkout@v3
- uses: hoverkraft-tech/[email protected]
with:
compose-file: "./docker/docker-compose.yml"
services: |
helloworld2
helloworld3
```