Skip to content

Commit

Permalink
⚙️ config(ci): Add workflow that tests the compose-based deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Apr 18, 2024
1 parent adbc81d commit d0d870e
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/ci:test:deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: ci:test:deploy

on:
push:
branches:
- main
pull_request:
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:

build:
name: Continuous integration (test deploy)
strategy:
matrix:
platform:
- ubuntu-latest

runs-on: ${{ matrix.platform }}

timeout-minutes: 4

steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Wait for image build workflow to succeed
uses: ArcticLampyrid/[email protected]
with:
workflow: ci:build:image.yml
sha: ${{ github.sha }}

- name: Log in to GitHub Packages registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Start
env:
ROOT_URL: http://localhost
IMAGE_TAG: sha-${{ github.sha }}
run: |
docker compose \
--env-file .env -f compose.yaml \
--env-file .deploy/ghcr.io/.env -f .deploy/ghcr.io/compose.yaml \
up --no-build --detach
- name: Wait for database container to be healthy
run: |
timeout 60 bash -c \
'until docker inspect --format "{{json .State.Health }}" "$(docker compose ps -q patient-db)" | jq -e ".Status == \"healthy\"" ; do sleep 1; done'
- name: Wait for web port to be available
run: |
timeout 60 bash -c \
'until nc -z -v -w5 127.0.0.1 3000 ; do sleep 1; done'
- name: Wait for web container to be healthy
run: |
timeout 60 bash -c \
'until docker inspect --format "{{json .State.Health }}" "$(docker compose ps -q patient-web)" | jq -e ".Status == \"healthy\"" ; do sleep 1; done'
- name: Call healthcheck endpoint
run: |
timeout 60 bash -c \
'curl -f http://localhost:3000/api/healthcheck'
- name: Run healthcheck script
run: |
timeout 60 bash -c \
'node scripts/healthcheck.cjs http://localhost:3000/api/healthcheck'
- name: Stop
run: |
docker compose down

0 comments on commit d0d870e

Please sign in to comment.