diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12029b1..d81bc37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,21 +13,17 @@ on: jobs: test: - runs-on: ubuntu-latest services: postgres: image: postgres:16 - env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: tasktracker - ports: - 5432:5432 - options: >- --health-cmd="pg_isready -U postgres" --health-interval=10s @@ -40,27 +36,38 @@ jobs: LOG_LEVEL: INFO steps: - - name: Checkout Repository - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: "3.12" - - name: Install Dependencies + - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt + python -m pip install -r requirements.txt - - name: Run Tests - run: | - pytest -v + - name: Run tests + run: python -m pytest -v - - name: Generate Coverage Report - run: | - pytest --cov=app --cov-report=term-missing + - name: Generate coverage report + run: python -m pytest --cov=app --cov-report=term-missing - - name: Build Docker Image - run: | - docker build -t tasktracker:latest . \ No newline at end of file + publish: + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') + needs: test + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/tasktracker:latest