diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 877bc506435..ea08f1598f6 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -182,7 +182,7 @@ jobs: uses: docker/build-push-action@v6 with: secrets: | - "sentry_auth_token=${{ secrets.SENTRY_AUTH_TOKEN }}" + "sentry_auth_token=${{ matrix.image == 'frontend' && secrets.SENTRY_AUTH_TOKEN }}" context: ${{ matrix.context }} target: ${{ matrix.target }} push: false @@ -203,6 +203,7 @@ jobs: FRONTEND_NODE_VERSION=${{ steps.prepare-build-args.outputs.frontend_node_version }} FRONTEND_PNPM_VERSION=${{ steps.prepare-build-args.outputs.frontend_pnpm_version }} PGCLI_VERSION=${{ steps.prepare-build-args.outputs.pgcli_version }} + ADD_SENTRY_RELEASE=${{ ((github.event_name == 'push' && github.repository == 'WordPress/openverse') || (github.event_name == 'workflow_dispatch' && inputs.perform_deploy)) }} ${{ matrix.build-args || '' }} - name: Upload image `${{ matrix.image }}` diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 9afa8ea94a9..89bcf6d4420 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -11,6 +11,7 @@ ARG FRONTEND_NODE_VERSION FROM docker.io/node:${FRONTEND_NODE_VERSION}-alpine AS builder ARG SEMANTIC_VERSION +ARG ADD_SENTRY_RELEASE # Install system packages needed to build on macOS RUN apk add --no-cache --virtual .gyp python3 make g++ \ @@ -46,11 +47,16 @@ ENV NODE_ENV=production # Increase memory limit for the build process (necessary for i18n routes) ENV NODE_OPTIONS="--max_old_space_size=4096" ENV SEMANTIC_VERSION=${SEMANTIC_VERSION} +ENV ADD_SENTRY_RELEASE=${ADD_SENTRY_RELEASE} + RUN --mount=type=secret,id=sentry_auth_token,mode=0444 \ - sh -c 'SENTRY_AUTH_TOKEN="$(cat /run/secrets/sentry_auth_token)" && \ - echo "SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN" >> .env.sentry-build-plugin' + sh -c 'if [ "$ADD_SENTRY_RELEASE" = "true" ]; then \ + SENTRY_AUTH_TOKEN="$(cat /run/secrets/sentry_auth_token)" && \ + echo "SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN" >> .env.sentry-build-plugin; \ + fi' \ +RUN printenv RUN pnpm build ############