From bb750c43a67e0d6fb3c213c56601f7724b545466 Mon Sep 17 00:00:00 2001 From: Olga Bulat Date: Wed, 18 Dec 2024 10:06:37 +0300 Subject: [PATCH] Fix conditional for secret --- .github/workflows/ci_cd.yml | 2 +- frontend/Dockerfile | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index f7754929358..cc2bd97cb89 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -183,7 +183,7 @@ jobs: with: # The Sentry auth token is only set for the production release of the frontend (on push to main or manual release). secrets: | - "sentry_auth_token=${{ matrix.image == 'frontend' && ((github.event_name == 'push' && github.repository == 'WordPress/openverse') ||(github.event_name == 'workflow_dispatch' && inputs.perform_deploy)) && secrets.SENTRY_AUTH_TOKEN || ''}}" + ${{ matrix.image == 'frontend' && ((github.event_name == 'push' && github.repository == 'WordPress/openverse') || (github.event_name == 'workflow_dispatch' && inputs.perform_deploy)) && format('sentry_auth_token={0}', secrets.SENTRY_AUTH_TOKEN) || '' }} context: ${{ matrix.context }} target: ${{ matrix.target }} push: false diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 911cb4a1f52..bf25a6a88be 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -47,9 +47,15 @@ ENV NODE_ENV=production ENV NODE_OPTIONS="--max_old_space_size=4096" ENV SEMANTIC_VERSION=${SEMANTIC_VERSION} -# Use the Sentry auth token secret to send the sourcemaps to Sentry +# Use the Sentry auth token secret to send the sourcemaps to Sentry only if the secret is provided RUN --mount=type=secret,id=sentry_auth_token,mode=0444 \ - SENTRY_AUTH_TOKEN="$(cat /run/secrets/sentry_auth_token)" pnpm build + sh -c 'if [ -f /run/secrets/sentry_auth_token ]; then \ + SENTRY_AUTH_TOKEN="$(cat /run/secrets/sentry_auth_token)"; \ + echo "Using Sentry Auth Token: $SENTRY_AUTH_TOKEN"; \ + else \ + echo "No Sentry Auth Token provided"; \ + fi' && pnpm build + ############ # Nuxt app #