-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (65 loc) · 2.08 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Build App
on:
pull_request:
branches: [ "main" ]
env:
SHA: ${{ github.sha }}
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }}
jobs:
run-api-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Start containers
run: |
docker compose build
docker image ls
docker compose up -d --force-recreate
- name: Wait for containers
run: |
docker ps
docker logs database
# max_attempts=3
# attempt=1
# while [ $attempt -le $max_attempts ]; do
# if curl -s http://0.0.0.0:8080/health | grep -q '"status":"OK"'; then
# echo "Container is up and healthy!"
# break
# else
# echo "Attempt $attempt/$max_attempts: Waiting for container..."
# attempt=$((attempt + 1))
# if [ $attempt -le $max_attempts ]; then
# sleep 60 # Wait for 60 seconds before the next attempt
# fi
# fi
# done
# if [ $attempt -gt $max_attempts ]; then
# echo "Container failed to become healthy after $max_attempts attempts."
# exit 1
# fi
# - name: Test
# run: go test -v ./...
# build-push-docker-image:
# runs-on: ubuntu-latest
# needs: run-api-tests
# steps:
# - uses: actions/checkout@v4
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Build and push todo-api
# uses: docker/build-push-action@v6
# with:
# push: true
# tags: ${{ secrets.DOCKERHUB_USERNAME }}/todo-api:${{ env.SHA }}
# - name: Build and push todo-db
# uses: docker/build-push-action@v6
# with:
# file: Dockerfile.db
# push: true
# tags: ${{ secrets.DOCKERHUB_USERNAME }}/todo-db:${{ env.SHA }}