Skip to content
Open
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
78 changes: 78 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Docker Build and Push

on:
push:
branches:
- develop
paths:
- 'api/Dockerfile'
- 'bot/Dockerfile'
- 'docker-compose.yml'
- 'api/**'
- 'bot/**'

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}


- name: Build and push API image
uses: docker/build-push-action@v4
with:
context: ./api
file: ./api/Dockerfile
push: true
tags: |
mzabiullah/onboarding-api:latest
mzabiullah/onboarding-api:${{ github.sha }}

#bot
- name: Build and push Bot image
uses: docker/build-push-action@v4
with:
context: ./bot
file: ./bot/Dockerfile
push: true
tags: |
mzabiullah/onboarding-bot:latest
mzabiullah/onboarding-bot:${{ github.sha }}


- name: Run docker-compose up
run: |
docker-compose up -d
- name: Wait for Postgres
run: |
echo "Waiting for postgres to be ready..."
for i in {1..20}; do
if docker exec postgres pg_isready -U myuser -d mydatabase; then
echo "Postgres is ready!"
break
fi
echo "Postgres is not ready yet, waiting..."
sleep 3
done

- name: Show docker-compose status

run: docker-compose ps


- name: Tear down docker-compose
if: always()
run: docker-compose down


7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Install PostgreSQL client
run: sudo apt-get update && sudo apt-get install -y postgresql-client

- name: Wait for Postgres to be ready
run: |
for i in {1..10}; do
pg_isready -h localhost -p 5432 && exit 0
for i in {1..20}; do
pg_isready -h localhost -p 5433 && exit 0
echo "Waiting for postgres..."
sleep 3
done
Expand Down
Loading