diff --git a/.github/workflows/image-sentry.yaml b/.github/workflows/image-sentry.yaml index fd388fdb2..e7bbdd907 100644 --- a/.github/workflows/image-sentry.yaml +++ b/.github/workflows/image-sentry.yaml @@ -8,6 +8,11 @@ on: name: Build Docker images with Sentry +permissions: + contents: read + packages: write + id-token: write + jobs: build-dev-image-with-sentry: name: Build development image with Sentry @@ -186,6 +191,7 @@ jobs: SENTRY_PROJECT=${{ secrets.SENTRY_PROJECT }} SENTRY_URL=${{ secrets.SENTRY_URL }} SENTRY_RELEASE=${{ steps.app_version.outputs.version }} + GITHUB_SHA=${{ github.sha }} VCS_REF=${{ github.repository }}@${{ github.sha }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 3c086e609..758b76fb5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,26 +14,30 @@ WORKDIR /app COPY . . ENV GITHUB_SHA=$GITHUB_SHA \ - SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN \ SENTRY_ORG=$SENTRY_ORG \ SENTRY_PROJECT=$SENTRY_PROJECT \ SENTRY_URL=$SENTRY_URL \ SENTRY_RELEASE=$SENTRY_RELEASE RUN ./scripts/prebuild.sh && \ - curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION=2.20.7 bash && \ - sentry-cli releases new "$SENTRY_RELEASE" || true && \ flutter build web --release --source-maps --dart-define=SENTRY_RELEASE=$SENTRY_RELEASE && \ - sentry-cli sourcemaps upload build/web \ - --org "$SENTRY_ORG" \ - --project "$SENTRY_PROJECT" \ - --auth-token "$SENTRY_AUTH_TOKEN" \ - --release "$SENTRY_RELEASE" \ - --dist "$GITHUB_SHA" \ - --url-prefix "~/" \ - --validate \ - --wait && \ - sentry-cli releases finalize "$SENTRY_RELEASE" + if [ -n "$SENTRY_AUTH_TOKEN" ] && [ -n "$SENTRY_ORG" ] && [ -n "$SENTRY_PROJECT" ] && [ -n "$SENTRY_RELEASE" ]; then \ + echo "Sentry configuration detected, uploading sourcemaps..." && \ + curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION=2.20.7 bash && \ + sentry-cli releases new "$SENTRY_RELEASE" || true && \ + sentry-cli sourcemaps upload build/web \ + --org "$SENTRY_ORG" \ + --project "$SENTRY_PROJECT" \ + --auth-token "$SENTRY_AUTH_TOKEN" \ + --release "$SENTRY_RELEASE" \ + --dist "$GITHUB_SHA" \ + --url-prefix "~/" \ + --validate \ + --wait || echo "Sentry sourcemaps upload failed, continuing build" && \ + sentry-cli releases finalize "$SENTRY_RELEASE" || echo "Sentry release finalize failed, continuing build"; \ + else \ + echo "Sentry configuration not complete, skipping sourcemap upload"; \ + fi FROM nginx:alpine RUN apk add gzip