Certified Backstage Associate (CBA)
Catalog
Demo Integrations Private Repository
In this guide, you’ll learn how to configure Backstage to pull catalog entities from a private GitHub repository. We’ll cover:
- Making a repo private
- Reviewing the
catalog-info.yaml
definition - Registering a component (and troubleshooting 404 errors)
- Setting up a GitHub integration with a Personal Access Token (PAT)
- Generating and securing a PAT
- Restarting Backstage and importing the entity
- Viewing your newly imported component
1. Convert Your Repository to Private
Start with your Backstage example repo (e.g., backstage-auth-service
) in a public state:
Steps:
- Go to Settings → Options → Change repository visibility.
- Choose Private, confirm, and authenticate if prompted.
Once done, your repo is no longer publicly accessible.
2. Review the Catalog Definition
Ensure your catalog-info.yaml
defines both a Component and an API:
apiVersion: backstage.io/v1beta1
kind: Component
metadata:
name: auth-service
description: authentication service
tags:
- javascript
links:
- url: https://google.com
title: Admin Dashboard
icon: dashboard
target: admin-dashboard
spec:
type: service
lifecycle: production
owner: guests
providesApis:
- auth-api
---
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: auth-api
description: Verify user authentication status
spec:
type: openapi
lifecycle: production
owner: guests
apiProvidedBy: auth-service
Copy the raw URL to this file (for example:https://raw.githubusercontent.com/<user>/backstage-auth-service/main/catalog-info.yaml
)
—you’ll use it to register the location in Backstage.
Note
Make sure the raw URL points to the main
branch (or your default branch). If you rename your branch, update the URL accordingly.
3. Attempt to Register the Component
Run the Backstage CLI command to register the existing catalog-info.yaml
location:
backstage-cli register-location \
--location "url:https://raw.githubusercontent.com/<user>/backstage-auth-service/main/catalog-info.yaml"
Because the repo is private, you’ll see a 404 error:
{
"error": {
"name": "InputError",
"message": "NotFoundError: Request failed for https://raw.githubusercontent.com/<user>/backstage-auth-service/main/catalog-info.yaml: 404 Not Found",
"stack": "..."
}
}
Warning
Backstage needs authentication to access private GitHub repos. Without a token, any raw.githubusercontent.com
request returns 404.
4. Configure the GitHub Integration
Edit your app-config.yaml
to allow reading from GitHub and provide your PAT via an environment variable:
# app-config.yaml
reading:
allow:
- host: 'raw.githubusercontent.com'
integrations:
github:
- host: github.com
token: ${GITHUB_TOKEN}
# For GitHub Enterprise use:
# apiBaseUrl: https://ghe.example.net/api/v3
# rawBaseUrl: https://ghe.example.net/raw
# token: ${GHE_TOKEN}
Table: GitHub Integration Settings
Setting | Description | Default / Example |
---|---|---|
host | GitHub host (public or enterprise) | github.com |
token | Personal Access Token (via env var) | ${GITHUB_TOKEN} |
apiBaseUrl | (Enterprise) API endpoint | https://ghe.example.net/api/v3 |
rawBaseUrl | (Enterprise) Raw content endpoint | https://ghe.example.net/raw |
4.1 Set the Environment Variable
After generating your PAT, export it in your shell:
export GITHUB_TOKEN=<your_personal_access_token>
Or—for demo purposes—embed it (not recommended for production):
integrations:
github:
- host: github.com
token: ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXX
5. Generate a GitHub Personal Access Token
- Navigate to Settings → Developer settings → Personal access tokens → Tokens (classic) → Generate new token (classic).
- Enter a name and expiration, then check the repo scope to allow reading private repos.
- Click Generate token and copy the token immediately.
GitHub will show the token only once:
Table: PAT Scopes for Private Repo Access
Scope | Purpose |
---|---|
repo | Read and write to code, commit statuses, issues |
6. Restart Backstage and Import the Component
Save your config changes, ensure GITHUB_TOKEN
is exported, and restart the dev server:
yarn dev
In the Backstage UI, navigate to Create → Import Existing Component, paste your raw URL, and click Review. Backstage will authenticate using your PAT and fetch the entity:
Click Import to complete the registration.
7. View the Imported Component
Head over to the Catalog in Backstage, select auth-service, and explore its overview, description, and relationships:
You’ve now configured Backstage to successfully fetch catalog entities from a private GitHub repository!
Links and References
Watch Video
Watch video content