Skip to content

Commit aa8a1a2

Browse files
committed
fix: handle fork builds without registry secrets
1 parent 056c412 commit aa8a1a2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
runs-on: ubuntu-latest
1919
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || github.event_name == 'pull_request'
2020

21+
env:
22+
PUSH_IMAGE: ${{ github.repository == 'EOPF-Explorer/data-pipeline' && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }}
23+
IMAGE_REGISTRY: ${{ secrets.OVH_HARBOR_REGISTRY || format('ghcr.io/{0}', github.repository_owner) }}
24+
2125
steps:
2226
- name: Checkout code
2327
uses: actions/checkout@v5
@@ -26,7 +30,7 @@ jobs:
2630
id: meta
2731
uses: docker/metadata-action@v5
2832
with:
29-
images: ${{ secrets.OVH_HARBOR_REGISTRY }}/eopf-sentinel-zarr-explorer/data-pipeline
33+
images: ${{ env.IMAGE_REGISTRY }}/eopf-sentinel-zarr-explorer/data-pipeline
3034
tags: |
3135
type=sha
3236
type=ref,event=branch
@@ -38,6 +42,7 @@ jobs:
3842
uses: docker/setup-buildx-action@v3
3943

4044
- name: Log in to OVH Container Registry
45+
if: env.PUSH_IMAGE == 'true'
4146
uses: docker/login-action@v3
4247
with:
4348
registry: ${{ secrets.OVH_HARBOR_REGISTRY }}
@@ -50,7 +55,7 @@ jobs:
5055
context: .
5156
file: docker/Dockerfile
5257
platforms: linux/amd64
53-
push: true
58+
push: ${{ env.PUSH_IMAGE == 'true' }}
5459
tags: ${{ steps.meta.outputs.tags }}
5560
labels: ${{ steps.meta.outputs.labels }}
5661
cache-from: type=gha

0 commit comments

Comments
 (0)