Interact with your GitHub Codespaces directly from Backstage platform.
npm install @adityasinghal26/plugin-github-codespaceshttp://localhost:7007/api/auth/github/handler/frame.
AUTH_GITHUB_CLIENT_ID and AUTH_GITHUB_CLIENT_SECRET environment variables.
github.com/project-slug.
yaml
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: backstage
description: backstage.io
annotations:
github.com/project-slug: 'backstage/backstage'
# Add below annotation for a custom devcontainer configuration with
# relative path of devcontainer.json file from root of the repository
github.com/devcontainer-path: .devcontainer/devcontainer.json
spec:
type: website
lifecycle: production
owner: user:guest
`
$3
1. Install the plugin dependency in your Backstage app package:
`bash
From your Backstage root directory
yarn add --cwd packages/app @adityasinghal26/plugin-github-codespaces
`
2. Add to the app EntityPage component:
`tsx
// In packages/app/src/components/catalog/EntityPage.tsx
import {
EntityGithubCodespacesWidget,
EntityGithubCodespacesCard,
EntityGithubCodespacesContent,
EntityGithubCodespacesRepoContent
isGithubCodespacesAvailable,
} from '@adityasinghal26/plugin-github-codespaces';
// Create the codespaces tab content for Github Codespaces
const codespacesContent = (
<>
{/* Add this entity switch to view the list
of codespaces filtered with entity name */}
{/* Add this entity switch to view the list
of codespaces filtered with repository */}
>
);
// You can add the overview widget and card to overviewContent as below
// this overview content can be used any number of pages
const overviewContent = (
{/ other grids... /}
{/ Add this entity switch to add the Start Codespace widget /}
Boolean(isGithubCodespacesAvailable(e))}>
{/* Add this entity switch to add the Start and List Codespace card.
You can set enableStart as 'true' to show the Start Codespace button.
If left unset or set as 'false', the Start Codespace button will be unavailable. */}
Boolean(isGithubCodespacesAvailable(e))}>
);
// You can add the tab to any number of pages, the service page is shown as an
// example here
const serviceEntityPage = (
{/ other tabs... /}
if={isGithubCodespacesAvailable}
path="/github-codespaces"
title="GitHub Codespaces">
{codespacesContent}
`
3. Run the app with yarn start and the backend with yarn start-backend.
Then navigate to /github-codespaces/ under any entity.
$3
Make sure that the required package is installed as in above section step #1.
1. Add to the app App.tsx component:
`tsx
// In packages/app/src/App.tsx
import { GithubCodespacesPage } from '@adityasinghal26/plugin-github-codespaces';
// Add the route to the App path routes
const routes = (
{/ other routes here /}
} />
);
`
2. Add to the app Root.tsx component:
`tsx
// In packages/app/src/components/Root/App.tsx
import { GitHubIcon } from '@backstage/core-components';
import { GithubCodespacesPage } from '@adityasinghal26/plugin-github-codespaces';
// Add the menu to the Root menu sidebar
export const Root = ({ children }: PropsWithChildren<{}>) => (
{/ other sidebar items here /}
{/ add inside "Menu" SidebarGroup /}
{/ other sidebar items here /}
{children}
);
`
Limitations
- Any codespace started using EntityGithubCodespacesWidget or EntityGithubCodespacesCard action will create a new codespace with the exact same display name as the entity name.
- Once the codespace is created, you can only start the Codespace from the Widget/Card action.
- The plugin does not support GitHub Enterprise yet. The feature will be extended in the next releases.