Enable GitHub Pages

Action ID: github:pages:enable
NPM Package:

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

Description

Enables GitHub Pages for a repository.

Input Schema

PropertyTypeDescriptionRequired
tokenstringThe token to use for authorization to GitHub
repoUrlstringAccepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username
buildTypestring-
sourcePathstring-
sourceBranchstringThe GitHub Pages source branch. Default is "main"

Output Schema

No output schema defined for this action.

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.

Copy
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.

Copy
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.

Copy
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.

Copy
steps:
  - id: enable-pages-minimal
    action: github:pages:enable
    input:
      repoUrl: github.com?repo=service-website&owner=jdoe

Enable 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.

Copy
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 }}