Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add docker flags input #115

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/ghadocs/examples/1_environment-variables.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- markdownlint-disable-next-line first-line-heading -->
<!-- markdownlint-disable first-line-heading -->

### Example Using environment variables

```yaml
Expand Down
5 changes: 3 additions & 2 deletions .github/ghadocs/examples/2_services.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!-- markdownlint-disable-next-line first-line-heading -->
<!-- markdownlint-disable first-line-heading -->

### Example using `services`

Perform `docker-compose up` to some given service instead of all of them
Perform `docker compose up` to some given service instead of all of them

```yaml
steps:
Expand Down
7 changes: 4 additions & 3 deletions .github/ghadocs/examples/3_up-flags.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!-- markdownlint-disable-next-line first-line-heading -->
<!-- markdownlint-disable first-line-heading -->

### Example using `up-flags`

Specify flags to pass to the `docker-compose up`. Default is none. Can be used
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/).
[docker compose up documentation](https://docs.docker.com/compose/reference/up/).
3 changes: 2 additions & 1 deletion .github/ghadocs/examples/4_down-flags.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- markdownlint-disable-next-line first-line-heading -->
<!-- markdownlint-disable first-line-heading -->

### Example using `down-flags`

Specify flags to pass to the `docker-compose down` command during cleanup.
Expand Down
7 changes: 4 additions & 3 deletions .github/ghadocs/examples/5_compose-flags.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<!-- markdownlint-disable-next-line first-line-heading -->
<!-- markdownlint-disable first-line-heading -->

### Example using `compose-flags`

Specify flags to pass to the `docker-compose` command. Default is none. A full
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).
[docker compose documentation](https://docs.docker.com/compose/reference/#command-options-overview-and-help).

```yaml
steps:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/__check-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,21 @@ jobs:
echo "Docker compose version is not in $DOCKER_COMPOSE_VERSION version"
exit 1
fi

test-action-with-docker-context:
runs-on: ubuntu-latest
name: Test with docker context
steps:
- uses: actions/checkout@v4

- name: Set up Docker
uses: docker/setup-docker-action@v4
with:
context: test-context

- name: Act
uses: ./
with:
docker-flags: "--context test-context"
compose-file: "./test/docker-compose.yml"
compose-version: "latest"
54 changes: 29 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@
<!-- end title -->
<!-- start badges -->

<a href="https%3A%2F%2Fgithub.com%2Fhoverkraft-tech%2Fcompose-action%2Freleases%2Flatest"><img src="https://img.shields.io/github/v/release/hoverkraft-tech/compose-action?display_name=tag&sort=semver&logo=github&style=flat-square" alt="Release%20by%20tag" /></a><a href="https%3A%2F%2Fgithub.com%2Fhoverkraft-tech%2Fcompose-action%2Freleases%2Flatest"><img src="https://img.shields.io/github/release-date/hoverkraft-tech/compose-action?display_name=tag&sort=semver&logo=github&style=flat-square" alt="Release%20by%20date" /></a><img src="https://img.shields.io/github/last-commit/hoverkraft-tech/compose-action?logo=github&style=flat-square" alt="Commit" /><a href="https%3A%2F%2Fgithub.com%2Fhoverkraft-tech%2Fcompose-action%2Fissues"><img src="https://img.shields.io/github/issues/hoverkraft-tech/compose-action?logo=github&style=flat-square" alt="Open%20Issues" /></a><img src="https://img.shields.io/github/downloads/hoverkraft-tech/compose-action/total?logo=github&style=flat-square" alt="Downloads" />
<a href="https%3A%2F%2Fgithub.com%2Fhoverkraft-tech%2Fcompose-action%2Freleases%2Flatest"><img src="https://img.shields.io/github/v/release/hoverkraft-tech/compose-action?display_name=tag&sort=semver&logo=github&style=flat-square" alt="Release%20by%20tag" /></a>
<a href="https%3A%2F%2Fgithub.com%2Fhoverkraft-tech%2Fcompose-action%2Freleases%2Flatest"><img src="https://img.shields.io/github/release-date/hoverkraft-tech/compose-action?display_name=tag&sort=semver&logo=github&style=flat-square" alt="Release%20by%20date" /></a>
<img src="https://img.shields.io/github/last-commit/hoverkraft-tech/compose-action?logo=github&style=flat-square" alt="Commit" />
<a href="https%3A%2F%2Fgithub.com%2Fhoverkraft-tech%2Fcompose-action%2Fissues"><img src="https://img.shields.io/github/issues/hoverkraft-tech/compose-action?logo=github&style=flat-square" alt="Open%20Issues" /></a>
<img src="https://img.shields.io/github/downloads/hoverkraft-tech/compose-action/total?logo=github&style=flat-square" alt="Downloads" />

<!-- end badges -->

</div>
<!-- start description -->

This action runs your docker-compose file and clean up before action finished
This action runs your [docker compose](https://docs.docker.com/reference/compose-file/) file and clean up before action finished

<!-- end description -->

Expand All @@ -30,16 +34,16 @@ This action runs your docker-compose file and clean up before action finished

### Action

The action will run `docker-compose up` to start the services defined in the given compose file(s).
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.
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.
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.
Some extra options can be passed to the `docker compose down` command using the `down-flags` input.

<!-- start usage -->

Expand All @@ -52,21 +56,21 @@ Some extra options can be passed to the `docker-compose down` command using the
# Default: ./docker-compose.yml
compose-file: ""

# Description: Services to perform docker-compose up.
# Description: Services to perform docker compose up.
#
services: ""

# Description: Additional options to pass to `docker-compose up` command.
# Description: Additional options to pass to `docker compose up` command.
#
# Default:
up-flags: ""

# Description: Additional options to pass to `docker-compose down` command.
# Description: Additional options to pass to `docker compose down` command.
#
# Default:
down-flags: ""

# Description: Additional options to pass to `docker-compose` command.
# Description: Additional options to pass to `docker compose` command.
#
# Default:
compose-flags: ""
Expand All @@ -82,7 +86,7 @@ Some extra options can be passed to the `docker-compose down` command using the
compose-version: ""

# Description: The GitHub token used to create an authenticated client (to fetch
# the latest version of docker-compose).
# the latest version of docker compose).
#
# Default: ${{ github.token }}
github-token: ""
Expand All @@ -97,13 +101,13 @@ Some extra options can be passed to the `docker-compose down` command using the
| **Input** | **Description** | **Default** | **Required** |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ | ------------ |
| <code>compose-file</code> | Path to compose file(s). It can be a list of files. It can be absolute or relative to the current working directory (cwd). | <code>./docker-compose.yml</code> | **false** |
| <code>services</code> | Services to perform docker-compose up. | | **false** |
| <code>up-flags</code> | Additional options to pass to <code>docker-compose up</code> command. | | **false** |
| <code>down-flags</code> | Additional options to pass to <code>docker-compose down</code> command. | | **false** |
| <code>compose-flags</code> | Additional options to pass to <code>docker-compose</code> command. | | **false** |
| <code>services</code> | Services to perform docker compose up. | | **false** |
| <code>up-flags</code> | Additional options to pass to <code>docker compose up</code> command. | | **false** |
| <code>down-flags</code> | Additional options to pass to <code>docker compose down</code> command. | | **false** |
| <code>compose-flags</code> | Additional options to pass to <code>docker compose</code> command. | | **false** |
| <code>cwd</code> | Current working directory | <code>${{ github.workspace }}</code> | **false** |
| <code>compose-version</code> | Compose version to use.<br />If null (default), it will use the current installed version.<br />If "latest", it will install the latest version. | | **false** |
| <code>github-token</code> | The GitHub token used to create an authenticated client (to fetch the latest version of docker-compose). | <code>${{ github.token }}</code> | **false** |
| <code>github-token</code> | The GitHub token used to create an authenticated client (to fetch the latest version of docker compose). | <code>${{ github.token }}</code> | **false** |

<!-- end inputs -->
<!-- start outputs -->
Expand All @@ -125,14 +129,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Run docker-compose
- 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
docker compose exec test-app pytest
```

<!-- start [.github/ghadocs/examples/] -->
Expand All @@ -152,7 +156,7 @@ steps:

### Example using `services`

Perform `docker-compose up` to some given service instead of all of them
Perform `docker compose up` to some given service instead of all of them

```yaml
steps:
Expand All @@ -168,24 +172,24 @@ steps:

### Example using `up-flags`

Specify flags to pass to the `docker-compose up`. Default is none. Can be used
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/).
[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.
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/).
[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
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).
[docker compose documentation](https://docs.docker.com/compose/reference/#command-options-overview-and-help).

```yaml
steps:
Expand Down
15 changes: 9 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
name: "Docker Compose Action"
description: "This action runs your docker-compose file and clean up before action finished"
description: "This action runs your compose file(s) and clean up before action finished"
author: "Hoverkraft"
branding:
icon: anchor
color: gray-dark

inputs:
docker-flags:
description: "Additional options to pass to `docker` command."
required: false
compose-file:
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)."
required: false
default: "./docker-compose.yml"
services:
description: "Services to perform docker-compose up."
description: "Services to perform docker compose up."
required: false
up-flags:
description: "Additional options to pass to `docker-compose up` command."
description: "Additional options to pass to `docker compose up` command."
required: false
default: ""
down-flags:
description: "Additional options to pass to `docker-compose down` command."
description: "Additional options to pass to `docker compose down` command."
required: false
default: ""
compose-flags:
description: "Additional options to pass to `docker-compose` command."
description: "Additional options to pass to `docker compose` command."
required: false
default: ""
cwd:
Expand All @@ -36,7 +39,7 @@ inputs:
If "latest", it will install the latest version.
required: false
github-token:
description: The GitHub token used to create an authenticated client (to fetch the latest version of docker-compose).
description: The GitHub token used to create an authenticated client (to fetch the latest version of docker compose).
default: ${{ github.token }}
required: false

Expand Down
12 changes: 11 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion dist/post.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading