|
1 | 1 | # Docker Compose Action |
2 | 2 |
|
3 | | -This action runs your docker-compose file, allows you to run tests and cleans up before action finished. |
| 3 | +This GitHub Action allows you to run your `docker-compose` files, specify services to bring up, execute tests in containers, and clean up afterward. It simplifies running tests within a containerized environment in your CI/CD pipelines. |
4 | 4 |
|
5 | 5 | ## Inputs |
6 | 6 |
|
7 | 7 | ### `compose-file` |
8 | 8 |
|
9 | | -**Optional** The name of the compose file. Default `"./docker-compose.yml"`. |
| 9 | +**Optional** - The path to the Docker Compose file(s). Default: `"./docker-compose.yml"`. |
10 | 10 |
|
11 | | -It can be a list of files: |
| 11 | +You can provide a list of files if needed: |
12 | 12 |
|
13 | | -```yml |
| 13 | +```yaml |
14 | 14 | compose-file: | |
15 | 15 | docker-compose.yml |
16 | 16 | docker-compose.ci.yml |
17 | 17 | ``` |
18 | 18 |
|
19 | 19 | ### `services` |
20 | 20 |
|
21 | | -**Optional** Just perform `docker-compose up` to one service instead of all of them |
| 21 | +**Optional** - The specific services to bring up with `docker-compose up`. If not specified, all services in the compose file(s) will be started. |
22 | 22 |
|
23 | 23 | ### `up-flags` |
24 | 24 |
|
25 | | -**Optional** Used to 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/). |
| 25 | +**Optional** - Additional flags to pass to the `docker-compose up` command. Default is none. Useful for passing options like `--build` or `--force-recreate`. |
26 | 26 |
|
27 | 27 | ### `down-flags` |
28 | 28 |
|
29 | | -**Optional** Used to 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/). |
| 29 | +**Optional** - Flags to pass to the `docker-compose down` command during cleanup. Default is none. For example, use `--volumes` if you want to remove volumes. |
30 | 30 |
|
31 | 31 | ### `compose-flags` |
32 | 32 |
|
33 | | -**Optional** Used to 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). |
| 33 | +**Optional** - General flags to pass to the `docker-compose` command. Default is none. These can be used to add global options like `--compatibility` or other Docker Compose features. |
34 | 34 |
|
35 | 35 | ### `test-container` |
36 | 36 |
|
37 | | -**Optional** Used to specify the container to run the tests in. Default is none. If not specified, no tests will be run. |
| 37 | +**Optional** - The name of the container in which to run the tests. If not specified, no tests will be executed. |
38 | 38 |
|
39 | 39 | ### `test-command` |
40 | 40 |
|
41 | | -**Optional** Used to specify the command to run the tests with. Default is none. If not specified, no tests will be run. |
| 41 | +**Optional** - The command used to run the tests within the container. For example, `npm test` for Node.js projects. If not specified, no tests will be run. |
| 42 | + |
| 43 | +### `annotate` |
| 44 | + |
| 45 | +**Optional** - Whether to show the console output of the test run as GitHub Action annotations. Default: `"true"`. |
42 | 46 |
|
43 | 47 | ## Example usage |
44 | 48 |
|
45 | 49 | ```yaml |
46 | 50 | steps: |
47 | | - # need checkout before using docker-compose-action |
48 | | - - uses: actions/checkout@v3 |
49 | | - - uses: adambirds/docker-compose-action@v1.3.0 |
| 51 | + # Check out the repository |
| 52 | + - uses: actions/checkout@v4 |
| 53 | +
|
| 54 | + # Run Docker Compose Action |
| 55 | + - uses: adambirds/docker-compose-action@v1.5.0 |
50 | 56 | with: |
51 | 57 | compose-file: "./docker/docker-compose.yml" |
| 58 | + up-flags: "--build" |
52 | 59 | down-flags: "--volumes" |
53 | | - services: | |
54 | | - helloworld2 |
55 | | - helloworld3 |
56 | | - test-container: helloworld |
| 60 | + test-container: "test-container" |
57 | 61 | test-command: "npm test" |
58 | 62 | ``` |
59 | 63 |
|
60 | 64 | ### Using environment variables |
61 | 65 |
|
62 | 66 | ```yaml |
63 | 67 | steps: |
64 | | - - uses: actions/checkout@v3 |
65 | | - - uses: adambirds/docker-compose-action@v1.3.0 |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + - uses: adambirds/docker-compose-action@v1.5.0 |
66 | 70 | with: |
67 | 71 | compose-file: "./docker/docker-compose.yml" |
68 | 72 | env: |
69 | 73 | CUSTOM_VARIABLE: "test" |
70 | 74 | ``` |
71 | 75 |
|
72 | | -### Run tests on multiple containers |
| 76 | +### Running tests on multiple containers |
73 | 77 |
|
74 | 78 | ```yaml |
75 | 79 | steps: |
76 | | - - uses: actions/checkout@v3 |
77 | | - - uses: adambirds/docker-compose-action@v1.3.0 |
| 80 | + - uses: actions/checkout@v4 |
| 81 | + - uses: adambirds/docker-compose-action@v1.5.0 |
78 | 82 | with: |
79 | 83 | compose-file: "./docker/docker-compose.yml" |
80 | 84 | test-container: "container1" |
81 | 85 | test-command: "npm test" |
82 | 86 |
|
83 | | - - uses: adambirds/docker-compose-action@v1.3.0 |
| 87 | + - uses: adambirds/docker-compose-action@v1.5.0 |
84 | 88 | with: |
85 | 89 | compose-file: "./docker/docker-compose.yml" |
86 | 90 | test-container: "container2" |
87 | 91 | test-command: "npm test" |
88 | 92 |
|
89 | | - - uses: adambirds/docker-compose-action@v1.3.0 |
| 93 | + - uses: adambirds/docker-compose-action@v1.5.0 |
90 | 94 | with: |
91 | 95 | compose-file: "./docker/docker-compose.yml" |
92 | 96 | test-container: "container3" |
|
0 commit comments