Skip to content

Instantly share code, notes, and snippets.

@kjenney
Created October 10, 2023 23:22
Show Gist options
  • Save kjenney/e398a09d68cffba8a4b175ce00656846 to your computer and use it in GitHub Desktop.
Save kjenney/e398a09d68cffba8a4b175ce00656846 to your computer and use it in GitHub Desktop.
Using Self-hosted Github instance with Backstage Scaffolder
app:
title: Test
baseUrl: http://localhost:3000
organization:
name: Test
backend:
# Used for enabling authentication, secret is shared by all backend plugins
# See https://backstage.io/docs/auth/service-to-service-auth for
# information on the format
# auth:
# keys:
# - secret: ${BACKEND_SECRET}
baseUrl: http://localhost:7007
listen:
port: 7007
# Uncomment the following host directive to bind to specific interfaces
# host: 127.0.0.1
csp:
connect-src: ["'self'", 'http:', 'https:']
img-src:
# "'self'" and 'data' are from the backstage default but must be set since img-src is overriden
- "'self'"
- 'data:'
# Allow your Jira instance for @roadiehq/backstage-plugin-jira
- 'JIRA_URL'
# Content-Security-Policy directives follow the Helmet format: https://helmetjs.github.io/#reference
# Default Helmet Content-Security-Policy values can be removed by setting the key to false
cors:
origin: http://localhost:3000
methods: [GET, HEAD, PATCH, POST, PUT, DELETE]
credentials: true
# This is for local development only, it is not recommended to use this in production
# The production database configuration is stored in app-config.production.yaml
database:
client: better-sqlite3
connection: ':memory:'
# workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir
integrations:
gitlab:
- host: ${GITLAB_HOST}
token: ${GITLAB_TOKEN}
apiBaseUrl: https://${GITLAB_HOST}/api/v4
proxy:
'/gitlab/api':
target: https://${GITLAB_HOST}/api/v4
allowedHeaders: ['PRIVATE-TOKEN']
headers:
PRIVATE-TOKEN: ${GITLAB_TOKEN}
Accept: application/json
'/jira/api':
target: ${JIRA_HOST}
headers:
Authorization: ${JIRA_TOKEN}
Accept: 'application/json'
Content-Type: 'application/json'
X-Atlassian-Token: 'no-check'
User-Agent: "AnyRandomString"
'/argocd/apidev':
target: https://127.0.0.1/api/v1/
changeOrigin: true
secure: false
headers:
Cookie: ${ARGOCD_AUTH_TOKEN}
jira:
# Defaults to /jira/api and can be omitted if proxy is configured for that url
proxyPath: /jira/api
# Add it in case your JIRA instance is connected to Confluence, in order to filter those activities
confluenceActivityFilter: wiki@uuid
# Defaults to latest and can be omitted if you want to use the latest version of the api
#apiVersion: 2
# Reference documentation http://backstage.io/docs/features/techdocs/configuration
# Note: After experimenting with basic setup, use CI/CD to generate docs
# and an external cloud storage when deploying TechDocs for production use-case.
# https://backstage.io/docs/features/techdocs/how-to-guides#how-to-migrate-from-techdocs-basic-to-recommended-deployment-approach
techdocs:
builder: 'local' # Alternatives - 'external'
generator:
runIn: 'local' # Alternatives - 'local'
publisher:
type: 'local' # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using alternatives.
auth:
# see https://backstage.io/docs/auth/ to learn about auth providers
environment: development
providers:
gitlab:
development:
clientId: ${GITLAB_OAUTH_CLIENT_ID}
clientSecret: ${GITLAB_OAUTH_CLIENT_SECRET}
audience: https://${GITLAB_HOST}
callbackUrl: http://localhost:7007/api/auth/gitlab/handler/frame
scaffolder:
# see https://backstage.io/docs/features/software-templates/configuration for software template options
catalog:
import:
entityFilename: catalog-info.yaml
pullRequestBranchName: backstage-integration
rules:
- allow: [Component, System, API, Resource, Location, User, Group]
locations:
- type: file
target: ../../config/entities.yaml
- type: file
target: ../../config/templates/infra-terraform/template.yaml
rules:
- allow: [Template]
- type: file
target: ../../config/org.yaml
rules:
- allow: [User, Group]
## Uncomment these lines to add more example data
# - type: url
# target: https://github.com/backstage/backstage/blob/master/packages/catalog-model/examples/all.yaml
## Uncomment these lines to add an example org
# - type: url
# target: https://github.com/backstage/backstage/blob/master/packages/catalog-model/examples/acme-corp.yaml
# rules:
# - allow: [User, Group]
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: infra-terraform
title: Infrastructure Terraform project
description: A template to create a GitLab repo with a pipeline for deploying Infrastructure with Terraform
spec:
type: service
parameters:
- title: Fill in some steps
required:
- name
properties:
name:
title: Name
type: string
description: Unique name of the component
ui:autofocus: true
ui:options:
rows: 5
description:
title: Description
type: string
description: Description of the component
targetPath:
title: Target Path in repo
type: string
description: Name of the directory to create in the repository
branchName:
title: Destination Branch Name
type: string
description: Name of the branch to create in the repository
assignee:
title: MR Assignee
type: string
description: GitLab Handle of the Assignee
- title: Choose a location
required:
- repoUrl
properties:
repoUrl:
title: Repository Location
type: string
ui:field: RepoUrlPicker
ui:options:
allowedHosts:
- gitlab.redacted.com
steps:
- id: template
name: Fetch Skeleton + Template
action: fetch:template
input:
url: ./content
targetPath: ${{ parameters.targetPath }}
values:
name: ${{parameters.name}}
- id: publish
name: Publish
action: publish:gitlab:merge-request
input:
repoUrl: ${{ parameters.repoUrl }}
title: Creating catalog-info.yaml ${{ parameters.name }} for backstage
branchName: ${{ parameters.branchName }}
description: |
# New project: ${{ parameters.name }}
${{ parameters.description if parameters.description }}
targetPath: ${{ parameters.targetPath if parameters.targetPath else '.' }}
token: ${{ env.GITLAB_TOKEN }}
commitAction: create
removeSourceBranch: true
assignee: ${{ parameters.assignee }}
output:
links:
- url: ${{ steps.publish.output.mergeRequestUrl }}
title: 'Go to Gitlab MR'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment