split build and push image and test in between

This commit is contained in:
Syed Ali Shahbaz
2023-09-29 11:55:30 +04:00
committed by GitHub
parent f7885eed69
commit d17064f67f

View File

@@ -92,15 +92,14 @@ jobs:
# [worker.oci]
# max-parallelism = 1
- name: Build and push image
- name: Build image
id: docker_build
uses: docker/build-push-action@v4
with:
context: ./
file: ./Dockerfile
# load: true
# push: false
push: ${{ github.event_name != 'pull_request' }}
load: true # Load the image into the Docker daemon
push: false # Do not push the image at this stage
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
@@ -116,12 +115,16 @@ jobs:
- name: Test runtime
run: |
docker run --rm --network stack \
-p 3000:3000 \
-e DATABASE_URL=postgresql://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@database/${{ env.POSTGRES_DB }} \
-e NEXTAUTH_SECRET=${{ env.NEXTAUTH_SECRET }} \
-e CALENDSO_ENCRYPTION_KEY=${{ env.CALENDSO_ENCRYPTION_KEY }} \
docker.io/calcom/cal.com:add-runtime-check &
tags="${{ steps.meta.outputs.tags }}"
IFS=',' read -ra ADDR <<< "$tags" # Convert string to array using ',' as delimiter
tag=${ADDR[0]} # Get the first tag
docker run --rm --network stack \
-p 3000:3000 \
-e DATABASE_URL=postgresql://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@database/${{ env.POSTGRES_DB }} \
-e NEXTAUTH_SECRET=${{ env.NEXTAUTH_SECRET }} \
-e CALENDSO_ENCRYPTION_KEY=${{ env.CALENDSO_ENCRYPTION_KEY }} \
$tag &
server_pid=$!
@@ -151,6 +154,23 @@ jobs:
NEXTAUTH_SECRET: 'EI4qqDpcfdvf4A+0aQEEx8JjHxHSy4uWiZw/F32K+pA='
CALENDSO_ENCRYPTION_KEY: '0zfLtY99wjeLnsM7qsa8xsT+Q0oSgnOL'
- name: Push image
uses: docker/build-push-action@v4
with:
context: .
# push: ${{ github.event_name != 'pull_request' }}
push: false
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
run: |
tags="${{ steps.meta.outputs.tags }}"
IFS=',' read -ra ADDR <<< "$tags" # Convert string to array using ',' as delimiter
tag=${ADDR[0]} # Get the first tag
docker push $tag
- name: Cleanup
run: |
docker compose down