diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f197d4c..56f5447 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,10 @@ jobs: runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || github.event_name == 'pull_request' + env: + PUSH_IMAGE: ${{ github.repository == 'EOPF-Explorer/data-pipeline' && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }} + IMAGE_REGISTRY: ${{ secrets.OVH_HARBOR_REGISTRY || format('ghcr.io/{0}', github.repository_owner) }} + steps: - name: Checkout code uses: actions/checkout@v5 @@ -26,7 +30,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ secrets.OVH_HARBOR_REGISTRY }}/eopf-sentinel-zarr-explorer/data-pipeline + images: ${{ env.IMAGE_REGISTRY }}/eopf-sentinel-zarr-explorer/data-pipeline tags: | type=sha type=ref,event=branch @@ -38,6 +42,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log in to OVH Container Registry + if: env.PUSH_IMAGE == 'true' uses: docker/login-action@v3 with: registry: ${{ secrets.OVH_HARBOR_REGISTRY }} @@ -50,7 +55,7 @@ jobs: context: . file: docker/Dockerfile platforms: linux/amd64 - push: true + push: ${{ env.PUSH_IMAGE == 'true' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha