From 630937aa061bdf6f646704c7c40e44617a69eba1 Mon Sep 17 00:00:00 2001 From: alavenant Date: Tue, 9 Jul 2024 16:54:40 +0200 Subject: [PATCH] Update cicd_docker.yml --- .github/workflows/cicd_docker.yml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cicd_docker.yml b/.github/workflows/cicd_docker.yml index 1adcbff..f4975d9 100644 --- a/.github/workflows/cicd_docker.yml +++ b/.github/workflows/cicd_docker.yml @@ -8,6 +8,8 @@ on: env: DOCKER_IMAGE_NAME: pdal_ign_plugin + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io jobs: build_docker_image_and_run_tests: @@ -24,4 +26,31 @@ jobs: - 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 }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v3 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}