Enables GitHub Pages for a repository.
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| token | string | The token to use for authorization to GitHub | |
| repoUrl | string | Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username | |
| buildType | string | - | |
| sourcePath | string | - | |
| sourceBranch | string | The GitHub Pages source branch. Default is "main" |
Output Schema
Usage Examples
Enable GitHub Pages with a GitHub Actions workflow after publishing a new repo
Enables Pages using the workflow build type right after creating and pushing a new repository. Use this when your site is deployed by a GitHub Actions workflow.
steps:
- id: fetch-base
action: [fetch:template](/backstage/scaffolder-actions/fetch-template/)
input:
url: ./skeletons/docs-site
- id: publish-repo
action: [publish:github](/backstage/scaffolder-actions/publish-github/)
input:
repoUrl: github.com?repo=${{ parameters.repoName }}&owner=${{ parameters.owner }}
defaultBranch: main
- id: enable-pages
action: github:pages:enable
input:
repoUrl: github.com?repo=${{ parameters.repoName }}&owner=${{ parameters.owner }}
buildType: workflow
token: ${{ secrets.githubToken }}Enable legacy Pages from the gh-pages branch
Configures Pages to serve static files from the gh-pages branch at the repository root. Use this when your CI publishes the built site to gh-pages.
steps:
- id: fetch-static-site
action: [fetch:template](/backstage/scaffolder-actions/fetch-template/)
input:
url: ./skeletons/static-site
- id: publish-repo
action: [publish:github](/backstage/scaffolder-actions/publish-github/)
input:
repoUrl: github.com?repo=${{ parameters.repoName }}&owner=${{ parameters.owner }}
defaultBranch: main
- id: enable-pages-legacy-gh-pages
action: github:pages:enable
input:
repoUrl: github.com?repo=${{ parameters.repoName }}&owner=${{ parameters.owner }}
buildType: legacy
sourceBranch: gh-pages
sourcePath: /
token: ${{ secrets.githubToken }}Enable legacy Pages from the /docs folder on main
Serves documentation from the /docs folder on the main branch. Use this for repositories that keep docs in a dedicated folder.
steps:
- id: fetch-docs
action: [fetch:template](/backstage/scaffolder-actions/fetch-template/)
input:
url: ./skeletons/repo-with-docs
- id: publish-repo
action: [publish:github](/backstage/scaffolder-actions/publish-github/)
input:
repoUrl: github.com?repo=${{ parameters.repoName }}&owner=${{ parameters.owner }}
defaultBranch: main
- id: enable-pages-legacy-docs
action: github:pages:enable
input:
repoUrl: github.com?repo=${{ parameters.repoName }}&owner=${{ parameters.owner }}
buildType: legacy
sourceBranch: main
sourcePath: /docs
token: ${{ secrets.githubToken }}Enable Pages on an existing repository with default settings
Turns on Pages for an existing repository using defaults. Use this when the repository already exists and you only need to enable Pages.
steps:
- id: enable-pages-minimal
action: github:pages:enable
input:
repoUrl: github.com?repo=service-website&owner=jdoeEnable workflow-based Pages for a repo with a non-main default branch
Enables Pages using the workflow build type for a repository that uses trunk as the default branch. Use this when your deployment is handled by a GitHub Actions workflow and your repo uses a nonstandard default branch.
steps:
- id: fetch-website
action: [fetch:template](/backstage/scaffolder-actions/fetch-template/)
input:
url: ./skeletons/website
- id: publish-repo
action: [publish:github](/backstage/scaffolder-actions/publish-github/)
input:
repoUrl: github.com?repo=${{ parameters.repoName }}&owner=${{ parameters.owner }}
defaultBranch: trunk
- id: enable-pages-workflow-trunk
action: github:pages:enable
input:
repoUrl: github.com?repo=${{ parameters.repoName }}&owner=${{ parameters.owner }}
buildType: workflow
token: ${{ secrets.githubToken }}