Skip to content

Commit 7d563aa

Browse files
authored
Merge pull request #5661 from qultoltd/QREPO-406-CI-error-in-forked-projects
Make CI workflow fork-friendly (skip GHCR login and Codecov on forks)
2 parents c557f2f + b9fe33c commit 7d563aa

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

.github/workflows/build.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ jobs:
4040
# Project name to use when running "docker compose" prior to e2e tests
4141
COMPOSE_PROJECT_NAME: 'ci'
4242
# Docker Registry to use for Docker compose scripts below.
43-
# We use GitHub's Container Registry to avoid aggressive rate limits at DockerHub.
44-
DOCKER_REGISTRY: ghcr.io
43+
# On the upstream dspace/dspace-angular repository we use GitHub's Container Registry
44+
# (ghcr.io) to avoid aggressive rate limits at DockerHub. Forks cannot authenticate
45+
# against ghcr.io/dspace/* with their own GITHUB_TOKEN (and the images there require
46+
# auth), so on forks we fall back to docker.io where the same images are public.
47+
DOCKER_REGISTRY: ${{ github.repository == 'dspace/dspace-angular' && 'ghcr.io' || 'docker.io' }}
4548
strategy:
4649
# Create a matrix of Node versions to test against (in parallel)
4750
matrix:
@@ -121,9 +124,14 @@ jobs:
121124
path: 'coverage/dspace-angular/lcov.info'
122125
retention-days: 14
123126

124-
# Login to our Docker registry, so that we can access private Docker images using "docker compose" below.
127+
# Login to our Docker registry, so that we can access Docker images using "docker compose" below.
128+
# This login is required on the upstream repository because DOCKER_REGISTRY is set to ghcr.io
129+
# and pulling ghcr.io/dspace/* requires authentication. On forks, DOCKER_REGISTRY falls back to
130+
# docker.io (see env block above) where the same images are publicly pullable without a login,
131+
# and forks cannot authenticate against ghcr.io/dspace/* with their own GITHUB_TOKEN anyway.
125132
- name: Login to ${{ env.DOCKER_REGISTRY }}
126133
uses: docker/login-action@v4
134+
if: github.repository == 'dspace/dspace-angular'
127135
with:
128136
registry: ${{ env.DOCKER_REGISTRY }}
129137
username: ${{ github.repository_owner }}
@@ -314,6 +322,9 @@ jobs:
314322
codecov:
315323
# Must run after 'tests' job above
316324
needs: tests
325+
# Only run on the upstream repository: forks do not have the CODECOV_TOKEN secret,
326+
# and Codecov refuses to create a commit on a protected branch without a token.
327+
if: github.repository == 'dspace/dspace-angular'
317328
runs-on: ubuntu-latest
318329
steps:
319330
- name: Checkout

0 commit comments

Comments
 (0)