diff --git a/.github/workflows/cicd_docker.yml b/.github/workflows/cicd_docker.yml index 9dc0179..46b5534 100644 --- a/.github/workflows/cicd_docker.yml +++ b/.github/workflows/cicd_docker.yml @@ -24,6 +24,12 @@ jobs: - name: Checkout branch uses: actions/checkout@v4 + # build "local" and test before build and deploy + - name: Build docker image + run: docker build -t ${{ env.DOCKER_IMAGE_NAME }}:test . + - name: Run tests in docker image + run: docker run ${{ env.DOCKER_IMAGE_NAME }}:test python -m pytest + # Login against a Docker registry except on PR # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} @@ -42,21 +48,24 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # Build and push Docker image with Buildx (don't push on PR) + # Build and push Docker image with Buildx (don't on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image id: build-and-push + if: ${{ github.event_name != 'pull_request' }} uses: docker/build-push-action@v5 with: context: . - push: ${{ github.event_name != 'pull_request' }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} # pull and test - name : Pull Docker image id: pull-image + if: github.event_name != 'pull_request' run: docker pull ${{ steps.meta.outputs.tags }} - name : Test Docker image id: test-image + if: github.event_name != 'pull_request' run: docker run ${{ steps.meta.outputs.tags }} python -m pytest