Skip to content

Commit

Permalink
🩹 fix: Use container id not service name in compose actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Apr 20, 2024
1 parent c8311b5 commit 43d3d45
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 6 deletions.
35 changes: 35 additions & 0 deletions .github/actions/compose-container/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: compose-container
description: >
Grabs the container of a given docker compose service.
inputs:

service:
required: true

outputs:

id:
description: >
The input service's container id.
value: ${{ steps.fetch.outputs.id }}

runs:

using: composite

steps:

- name: Retrieve service container id

id: fetch

env:
SERVICE: ${{ inputs.service }}

shell: bash

run: |
CONTAINER_ID="$(docker compose ps -q "${SERVICE}")"
echo "id=${CONTAINER_ID}" >> "$GITHUB_OUTPUT"
test -n "${CONTAINER_ID}"
3 changes: 2 additions & 1 deletion .github/actions/ip-address/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ip-address
description: >
Grabs a given container's IP address.
Grabs the IP address of a given container.
inputs:

Expand Down Expand Up @@ -32,3 +32,4 @@ runs:
run: |
CONTAINER_IP_ADDRESS="$(docker container inspect --format '{{ range.NetworkSettings.Networks }}{{ .IPAddress }}{{ end }}' "${NAME_OR_ID}")"
echo "address=${CONTAINER_IP_ADDRESS}" >> "$GITHUB_OUTPUT"
test -n "${CONTAINER_IP_ADDRESS}"
16 changes: 13 additions & 3 deletions .github/workflows/ci:build:compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,15 @@ jobs:
run: |
docker compose up --no-build --detach
- name: Wait for web container to be healthy
- id: patient-db-container
uses: ./.github/actions/compose-container
with:
service: patient-db

- name: Wait for db container to be healthy
uses: ./.github/actions/is-healthy
with:
container: patient-db
container: ${{ steps.patient-db-container.outputs.id }}
timeout: 60

- name: Wait for web port to be available
Expand All @@ -103,10 +108,15 @@ jobs:
timeout: 60
port: 3000

- id: patient-web-container
uses: ./.github/actions/compose-container
with:
service: patient-web

- name: Wait for web container to be healthy
uses: ./.github/actions/is-healthy
with:
container: patient-web
container: ${{ steps.patient-web-container.outputs.id }}
timeout: 60

- name: Call healthcheck endpoint
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/ci:test:deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@ jobs:
--env-file .deploy/ghcr.io/.env -f .deploy/ghcr.io/compose.yaml \
up --no-build --detach
- id: patient-db-container
uses: ./.github/actions/compose-container
with:
service: patient-db

- name: Wait for database container to be healthy
uses: ./.github/actions/is-healthy
with:
container: patient-db
container: ${{ steps.patient-db-container.outputs.id }}
timeout: 60

- name: Wait for web port to be available
Expand All @@ -63,10 +68,15 @@ jobs:
timeout: 60
port: 3000

- id: patient-web-container
uses: ./.github/actions/compose-container
with:
service: patient-web

- name: Wait for web container to be healthy
uses: ./.github/actions/is-healthy
with:
container: patient-web
container: ${{ steps.patient-web-container.outputs.id }}
timeout: 60

- name: Call healthcheck endpoint
Expand Down

0 comments on commit 43d3d45

Please sign in to comment.