Fetch Sentry DSN

Action ID: sentry:fetch:dsn
NPM Package:

@backstage/plugin-scaffolder-backend-module-sentry

Description

Fetches the public DSN for a specified Sentry project using authenticated access.

Input Schema

PropertyTypeDescriptionRequired
authTokenstringauthenticate via bearer auth token. Requires one of the following scopes: project:admin, project:read, project:write
projectSlugstringThe slug of the project to fetch the DSN for
organizationSlugstringThe slug of the organization the project belongs to

Output Schema

PropertyTypeDescriptionRequired
dsnstringThe public DSN of the Sentry project

Usage Examples

Inject a Sentry DSN into app-config.yaml during service creation

Fetches the DSN for a specified project using a token and injects it into an application config using fetch:template. Use this when you want DSN wired into your service config at scaffold time.

Copy
steps:
  - id: getSentryDsn
    action: sentry:fetch:dsn
    input:
      organizationSlug: ${{ parameters.sentryOrg }}
      projectSlug: ${{ parameters.sentryProject }}
      authToken: ${{ parameters.sentryAuthToken }}

  - id: renderAppConfig
    action: fetch:template
    input:
      url: ./skeletons/node-service
      targetPath: .
      values:
        serviceName: ${{ parameters.serviceName }}
        sentry:
          dsn: ${{ steps.getSentryDsn.output.dsn }}

Write DSN to a .env file without providing an explicit token

Fetches the DSN using default authentication and writes it to an .env file template. Use this when credentials are configured for the action and you want the DSN available as an environment variable. The DSN is also logged with debug:log.

Copy
steps:
  - id: getDsnStaging
    action: sentry:fetch:dsn
    input:
      organizationSlug: ${{ parameters.sentryOrg }}
      projectSlug: ${{ parameters.stagingProject }}

  - id: logStagingDsn
    action: debug:log
    input:
      message: "Fetched Sentry DSN for staging ${{ steps.getDsnStaging.output.dsn }}"

  - id: writeEnv
    action: fetch:template
    input:
      url: ./templates/env
      targetPath: .
      values:
        ENVIRONMENT: staging
        SENTRY_DSN: ${{ steps.getDsnStaging.output.dsn }}

Configure DSNs for frontend and backend projects in a monorepo

Fetches DSNs for two Sentry projects and renders separate config files for frontend and backend using fetch:template. Use this when your repo hosts multiple apps with distinct Sentry projects.

Copy
steps:
  - id: getFrontendDsn
    action: sentry:fetch:dsn
    input:
      organizationSlug: ${{ parameters.sentryOrg }}
      projectSlug: ${{ parameters.frontendProject }}
      authToken: ${{ parameters.sentryAuthToken }}

  - id: getBackendDsn
    action: sentry:fetch:dsn
    input:
      organizationSlug: ${{ parameters.sentryOrg }}
      projectSlug: ${{ parameters.backendProject }}
      authToken: ${{ parameters.sentryAuthToken }}

  - id: renderFrontendConfig
    action: fetch:template
    input:
      url: ./templates/frontend
      targetPath: packages/frontend
      values:
        appName: ${{ parameters.frontendName }}
        sentryDsn: ${{ steps.getFrontendDsn.output.dsn }}

  - id: renderBackendConfig
    action: fetch:template
    input:
      url: ./templates/backend
      targetPath: packages/backend
      values:
        serviceName: ${{ parameters.backendName }}
        sentryDsn: ${{ steps.getBackendDsn.output.dsn }}

Generate a Kubernetes ConfigMap with Sentry DSN and publish to GitHub

Fetches the DSN and renders a Kubernetes ConfigMap manifest that is then pushed to a new repository with publish:github. Use this when you manage environment config in Git.

Copy
steps:
  - id: getSentryDsn
    action: sentry:fetch:dsn
    input:
      organizationSlug: acme
      projectSlug: shopping-cart
      authToken: ${{ parameters.sentryAuthToken }}

  - id: renderK8sConfig
    action: fetch:template
    input:
      url: ./templates/k8s-config
      targetPath: .
      values:
        app: shopping-cart
        sentryDsn: ${{ steps.getSentryDsn.output.dsn }}

  - id: publishRepo
    action: publish:github
    input:
      repoUrl: github.com?owner=acme-platform&repo=shopping-cart-config

Add DSN to catalog-info.yaml and register the component

Fetches the DSN and writes it into catalog-info.yaml as an annotation, then registers the new component using catalog:register. Use this when you want the DSN discoverable from the Backstage catalog.

Copy
steps:
  - id: fetchDsn
    action: sentry:fetch:dsn
    input:
      organizationSlug: ${{ parameters.sentryOrg }}
      projectSlug: ${{ parameters.projectSlug }}
      authToken: ${{ parameters.sentryAuthToken }}

  - id: renderCatalogInfo
    action: fetch:template
    input:
      url: ./templates/catalog
      targetPath: .
      values:
        name: ${{ parameters.componentName }}
        annotations:
          sentry.io/dsn: ${{ steps.fetchDsn.output.dsn }}

  - id: publishRepo
    action: publish:github
    input:
      repoUrl: github.com?owner=${{ parameters.repoOwner }}&repo=${{ parameters.repoName }}

  - id: registerInCatalog
    action: catalog:register
    input:
      repoContentsUrl: ${{ steps.publishRepo.output.repoContentsUrl }}