fix the health check issue in the compose #60
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI (build, test and push to the registry) | |
on: | |
push: | |
branches: [ "main" ] | |
paths-ignore: ["**/*.md"] | |
pull_request: | |
branches: [ "main" ] | |
paths-ignore: ["**/*.md"] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create .env file | |
run: | | |
cat << EOF > .env | |
POSTGRES_USER=${{ secrets.POSTGRES_USER }} | |
POSTGRES_PASSWD=${{ secrets.POSTGRES_PASSWORD }} | |
REDIS_PASSWD=${{ secrets.REDIS_PASSWD }} | |
POSTGRES_HOST=${{ vars.POSTGRES_HOST }} | |
POSTGRES_DB=${{ vars.POSTGRES_DB }} | |
EOF | |
- name: Build and Run | |
run: | | |
docker compose up -d | |
docker ps | |
- name: Health check | |
run: | | |
sleep 60 | |
docker ps | |
docker logs app | |
echo ------ | |
docker logs database | |
curl --fail http://localhost:8000/healthz 1>&2 2>/dev/null | |
test: | |
runs-on: ubuntu-24.04 | |
needs: build | |
strategy: | |
# max-parallel: 3 | |
matrix: | |
python-version: [3.9] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
cd src | |
python -m pip install --upgrade pip | |
pip install -r Requirements.txt | |
- name: Run tests | |
run: python src/manage.py test | |
push_image: | |
runs-on: ubuntu-24.04 | |
needs: test | |
if: github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build | |
run: docker compose build | |
- name: push docker image | |
run: | | |
docker tag ozennou/ronda_game:latest ozennou/ronda_game:0.0.${GITHUB_RUN_NUMBER}v | |
docker push ozennou/ronda_game:0.0.${GITHUB_RUN_NUMBER}v | |
docker push ozennou/ronda_game:latest |