Skip to content

Commit a3e3c7d

Browse files
committed
m: refine ci
1 parent 30194f1 commit a3e3c7d

5 files changed

Lines changed: 168 additions & 217 deletions

File tree

.github/workflows/cd.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ permissions:
1111

1212
env:
1313
DOCKER_ENV_REGISTRY: ${{ vars.DOCKER_ENV_REGISTRY }}
14-
DOCKER_ENV_TAG: ${{ github.sha }}
14+
DOCKER_ENV_BASE_TAG: ${{ github.sha }}
1515

1616
jobs:
1717
tag_dev_image:
@@ -31,7 +31,7 @@ jobs:
3131
run: |
3232
RETRIES=3
3333
while [ $RETRIES -gt 0 ]; do
34-
if ./docker/env.sh pull; then
34+
if ./docker/env.sh compose pull; then
3535
exit 0
3636
else
3737
echo "Retrying in 1 minute"
@@ -41,8 +41,7 @@ jobs:
4141
done
4242
exit 1
4343
44-
- name: Tag dev env images with version
45-
run: ./docker/env.sh tag ${{ github.ref_name }}
46-
47-
- name: Push tagged dev env images
48-
run: ./docker/env.sh push
44+
- name: Tag and push dev env images
45+
run: |
46+
./docker/env.sh tag ${{ github.ref_name }}
47+
DOCKER_ENV_BASE_TAG=${{ github.ref_name }} ./docker/env.sh compose push

.github/workflows/ci_branch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ jobs:
3030
run: ./docker/env.sh exec -- ./scripts/lint.sh
3131

3232
- name: Wind down docker-env
33-
run: ./docker/env.sh down
33+
run: ./docker/env.sh compose down

.github/workflows/ci_master.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ permissions:
1212
env:
1313
DOCKER_ENV_REGISTRY: ${{ vars.DOCKER_ENV_REGISTRY }}
1414
DOCKER_ENV_BUILD_PLATFORMS: linux/arm64,linux/amd64
15+
DOCKER_ENV_BUILD_TAGS: ${{ github.sha }}
1516

1617
jobs:
1718
cache_dev_image:
@@ -33,11 +34,5 @@ jobs:
3334
- name: Clone project
3435
uses: actions/checkout@v4
3536

36-
- name: Build dev env images
37-
run: ./docker/env.sh build
38-
39-
- name: Tag dev env images with commit
40-
run: ./docker/env.sh tag ${{ github.sha }}
41-
42-
- name: Push tagged dev env images
43-
run: ./docker/env.sh push
37+
- name: Build, tag and push dev env images
38+
run: ./docker/env.sh compose build --push

docs/README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,15 @@ You can customize the following environment variables:
4444

4545
<!-- markdownlint-disable MD013 -->
4646

47-
| var | default | description |
48-
| ------------------------------------- | --------------------------------------------------- | ---------------------------------------------------------------- |
49-
| `DOCKER_ENV_PROJECT_NAME` | Repository name | Name of your project (used to generated images and containers) |
50-
| `DOCKER_ENV_PROJECT_ENV_FILE` | `$PWD/.env` | Local environment file |
51-
| `DOCKER_ENV_PROJECT_DOCKER_DIRECTORY` | `$PWD/docker` | Project docker directory, where docker-env files are located |
52-
| `DOCKER_ENV_PROJECT_COMPOSE_FILE` | `$DOCKER_ENV_PROJECT_DOCKER_DIRECTORY/compose.yaml` | The dev env compose file, where services are defined |
53-
| `DOCKER_ENV_PROJECT_CACHE_DIRECTORY` | `$PWD/.cache/docker-env` | Where docker-env will store its generated files for your project |
54-
| `DOCKER_ENV_PROJECT_DEFAULT_SERVICE` | dev | Default dev env service to use when unspecified |
55-
| `DOCKER_ENV_BUILD_PLATFORMS` | - | Target platforms when building images |
56-
| `DOCKER_ENV_REGISTRY` | - | Registry where built images will be pulled/pushed from/to |
57-
| `DOCKER_ENV_TAG` | latest | Image tag to build/pull from registry |
47+
| var | default | description |
48+
| ------------------------------------ | ----------------------- | ---------------------------------------------------------------- |
49+
| `DOCKER_ENV_PROJECT_NAME` | Repository name | Name of your project (used to generated images and containers) |
50+
| `DOCKER_ENV_PROJECT_COMPOSE_FILE` | `./docker/compose.yaml` | The dev env compose file, where services are defined |
51+
| `DOCKER_ENV_PROJECT_CACHE_DIRECTORY` | `./.cache/docker-env` | Where docker-env will store its generated files for your project |
52+
| `DOCKER_ENV_PROJECT_DEFAULT_SERVICE` | dev | Default dev env service to use when unspecified |
53+
| `DOCKER_ENV_BUILD_PLATFORMS` | - | Target platforms when building images |
54+
| `DOCKER_ENV_REGISTRY` | - | Registry where built images will be pulled/pushed from/to |
55+
| `DOCKER_ENV_BASE_TAG` | latest | Image tag to build/pull from registry |
5856

5957
These variables are readonly:
6058

@@ -102,15 +100,16 @@ create containers, start them and open an interactive shell in the dev env conta
102100
#### CI workflows
103101

104102
You can use `./docker/env.sh exec -- COMMAND` to build/pull images, create containers, start
105-
them and execute a command in the dev env container. The `init`, `build`, `pull`, `push` and
106-
`tag` subcommands, alongside some [environment variables](#environment-variables) can also be
107-
used to craft efficient workflows.
103+
them and execute a command in the dev env container. The `compose` and `tag` subcommands,
104+
alongside some [environment variables](#environment-variables) can also be used to craft
105+
efficient workflows.
108106

109107
> You can look at this repo's CI/CD workflows for inspiration
110108
111109
#### Winding down
112110

113-
When done, you can stop and remove the environment using `./docker/env.sh down`
111+
When done, you can stop and remove the environment using `./docker/env.sh compose down` (like
112+
any other docker compose environment)
114113

115114
## Contributors
116115

0 commit comments

Comments
 (0)