From c3cbd7b15855b1746b2abde28bb86f836ce33f45 Mon Sep 17 00:00:00 2001 From: Pascal Delange Date: Mon, 23 Oct 2023 11:04:47 +0200 Subject: [PATCH] bundled commits --- .github/workflows/build_and_deploy.yaml | 19 +++++++++++++++++++ .github/workflows/main_push.yaml | 10 +--------- Dockerfile | 11 ++++++++--- package.json | 2 +- packages/app-builder/.env.local | 1 - .../src/utils/environment.server.ts | 1 - pnpm-lock.yaml | 8 ++++---- 7 files changed, 33 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index c09e6f11e..c4324de4a 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -15,6 +15,9 @@ on: GCP_SA_KEY: required: true description: 'GCP Service Account Key' + SENTRY_AUTH_TOKEN: + required: true + description: 'Sentry Auth Token' jobs: main: @@ -41,13 +44,29 @@ jobs: username: _json_key password: ${{ secrets.GCP_SA_KEY }} + - name: Setup Sentry CLI + uses: mathieu-bour/setup-sentry-cli@v1 + with: + token: ${{ secrets.SENTRY_AUTH_TOKEN }} + organization: 'checkmarble' + project: 'marble-frontend' + + - name: Get release + run: | + echo "SENTRY_RELEASE=$(sentry-cli releases propose-version)" >> "$GITHUB_ENV" + # source: https://github.com/docker/build-push-action - name: Build and push uses: docker/build-push-action@v5 with: + context: . push: true target: app-builder tags: ${{ env.IMAGE }} + build-args: | + "SENTRY_RELEASE=${{ env.SENTRY_RELEASE }}" + secrets: | + "SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}" - name: Auth uses: 'google-github-actions/auth@v1' diff --git a/.github/workflows/main_push.yaml b/.github/workflows/main_push.yaml index 0b8a519d1..bc6997187 100644 --- a/.github/workflows/main_push.yaml +++ b/.github/workflows/main_push.yaml @@ -16,15 +16,6 @@ jobs: actions: read uses: ./.github/workflows/check.yaml - create_sentry_release: - uses: getsentry/action-release@v1 - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_ORG: checkmarble - SENTRY_PROJECT: marble-frontend - with: - environment: production - build_and_deploy: needs: check permissions: @@ -36,3 +27,4 @@ jobs: version: latest secrets: GCP_SA_KEY: ${{ secrets.GCP_SA_KEY_STAGING }} + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} diff --git a/Dockerfile b/Dockerfile index 9e172d718..71a66a8da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,23 @@ FROM node:20-slim AS base ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" +ARG SENTRY_RELEASE +ENV SENTRY_RELEASE=$SENTRY_RELEASE RUN corepack enable +RUN apt-get update +RUN apt-get -y install ca-certificates COPY . /app WORKDIR /app FROM base AS prod-deps -# RUN --mount=type=cache,id=pnpm,target=$PNPM_HOME/store pnpm install --prod --frozen-lockfile RUN pnpm install --prod --frozen-lockfile FROM base AS build -# RUN --mount=type=cache,id=pnpm,target=$PNPM_HOME/store pnpm install --frozen-lockfile RUN pnpm install --frozen-lockfile -RUN pnpm run -r build-with-sourcemaps +RUN --mount=type=secret,id=SENTRY_AUTH_TOKEN \ + SENTRY_AUTH_TOKEN=$(cat /run/secrets/SENTRY_AUTH_TOKEN) && \ + export SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN && \ + pnpm run -r build-with-sourcemaps --release $SENTRY_RELEASE FROM base AS app-builder ENV NODE_ENV=production diff --git a/package.json b/package.json index e6a882dcd..ff0544d03 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "devDependencies": { "@remix-run/dev": "^1.19.3", "@remix-run/eslint-config": "^1.19.3", + "@sentry/cli": "^2.21.2", "@svgr/core": "^8.1.0", "@svgr/plugin-jsx": "^8.1.0", "@svgr/plugin-prettier": "^8.1.0", @@ -73,7 +74,6 @@ "@remix-run/node": "^1.19.3", "@remix-run/react": "^1.19.3", "@remix-run/serve": "^1.19.3", - "@sentry/cli": "^2.21.2", "@sentry/remix": "^7.74.0", "@tanstack/react-table": "^8.10.6", "@tanstack/react-virtual": "3.0.0-beta.61", diff --git a/packages/app-builder/.env.local b/packages/app-builder/.env.local index ca490bb12..008457731 100644 --- a/packages/app-builder/.env.local +++ b/packages/app-builder/.env.local @@ -17,6 +17,5 @@ FIREBASE_STORAGE_BUCKET=tokyo-country-381508.appspot.com FIREBASE_MESSAGING_SENDER_ID=1047691849054 FIREBASE_APP_ID=1:1047691849054:web:a5b69dd2ac584c1160b3cf -SENTRY_AUTH_TOKEN=dummy SENTRY_DSN=dummy SENTRY_ENVIRONMENT=development diff --git a/packages/app-builder/src/utils/environment.server.ts b/packages/app-builder/src/utils/environment.server.ts index 06baab107..d48d095ce 100644 --- a/packages/app-builder/src/utils/environment.server.ts +++ b/packages/app-builder/src/utils/environment.server.ts @@ -36,7 +36,6 @@ type ServerPublicEnvVarName = | 'MARBLE_API_DOMAIN' | 'MARBLE_APP_DOMAIN' | 'NODE_ENV' - | 'SENTRY_AUTH_TOKEN' | 'SENTRY_DSN' | 'SENTRY_ENVIRONMENT' | 'SESSION_MAX_AGE'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 56f0aa3d5..96fad1475 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -62,9 +62,6 @@ importers: '@remix-run/serve': specifier: ^1.19.3 version: 1.19.3 - '@sentry/cli': - specifier: ^2.21.2 - version: 2.21.2 '@sentry/remix': specifier: ^7.74.0 version: 7.74.0(@remix-run/node@1.19.3)(@remix-run/react@1.19.3)(react@18.2.0) @@ -165,6 +162,9 @@ importers: '@remix-run/eslint-config': specifier: ^1.19.3 version: 1.19.3(eslint@8.44.0)(react@18.2.0)(typescript@5.1.6) + '@sentry/cli': + specifier: ^2.21.2 + version: 2.21.2 '@svgr/core': specifier: ^8.1.0 version: 8.1.0(typescript@5.1.6) @@ -5119,7 +5119,7 @@ packages: transitivePeerDependencies: - encoding - supports-color - dev: false + dev: true /@sentry/core@7.74.0: resolution: {integrity: sha512-83NRuqn7nDZkSVBN5yJQqcpXDG4yMYiB7TkYUKrGTzBpRy6KUOrkCdybuKk0oraTIGiGSe5WEwCFySiNgR9FzA==}