Skip to content

Commit

Permalink
Update cicd_docker.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
alavenant authored Jul 10, 2024
1 parent a9b6040 commit 5c3f55d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/cicd_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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

0 comments on commit 5c3f55d

Please sign in to comment.