diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/docker-build-push.yaml new file mode 100644 index 0000000..6d6ccaa --- /dev/null +++ b/.github/workflows/docker-build-push.yaml @@ -0,0 +1,43 @@ +name: Build and Push Docker Images +on: + push: + tags: + - "backend*" +env: + REGISTRY: ghcr.io + BACKEND_IMAGE_NAME: ${{ github.repository_owner }}/study-app-api +jobs: + build-and-push-backend: + name: Build and Push Backend + runs-on: ubuntu-latest + # Only run for backend tags + if: contains(github.ref, 'backend') + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract tag name + id: tag + run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Build and push Backend Docker image + uses: docker/build-push-action@v5 + with: + context: ./src/backend + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:${{ steps.tag.outputs.TAG }} + ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:latest + outputs: + tag: ${{ steps.tag.outputs.TAG }} + app: backend diff --git a/src/backend/src/backend/main.py b/src/backend/src/backend/main.py index e346e16..4bd6961 100644 --- a/src/backend/src/backend/main.py +++ b/src/backend/src/backend/main.py @@ -98,6 +98,7 @@ async def read_stats(): # Marker for CI pipeline # This comment is used to trigger the CI pipeline when changes are made to this file. +# This comment is used to trigger the CI pipeline when changes are made to this file. def main():