Skip to main content

Configuring a publishing source for your GitHub Pages site

You can configure your GitHub Pages site to publish when changes are pushed to a specific branch, or you can write a GitHub Actions workflow to publish your site.

People with admin or maintainer permissions for a repository can configure a publishing source for a GitHub Pages site.

GitHub Pagesは、GitHub Free及びOrganizationのGitHub Freeのパブリックリポジトリ、GitHub Pro、GitHub Team、GitHub Enterprise Cloud、GitHub Enterprise Serverのパブリック及びプライベートリポジトリで利用できます。 詳しい情報については「GitHubの製品」を参照してください。

About publishing sources

You can publish your site when changes are pushed to a specific branch, or you can write a GitHub Actions workflow to publish your site.

If you do not need any control over the build process for your site, we recommend that you publish your site when changes are pushed to a specific branch. You can specify which branch and folder to use as your publishing source. The source branch can be any branch in your repository, and the source folder can either be the root of the repository (/) on the source branch or a /docs folder on the source branch. Whenever changes are pushed to the source branch, the changes in the source folder will be published to your GitHub Pages site.

If you want to use a build process other than Jekyll or you do not want a dedicated branch to hold your compiled static files, we recommend that you write a GitHub Actions workflow to publish your site. GitHub Enterprise Cloud provides starter workflows for common publishing scenarios to help you write your workflow.

Warning: Unless your enterprise uses Enterprise Managed Users, GitHub Pages sites are publicly available on the internet by default, even if the repository for the site is private or internal. You can publish a site privately by managing access control for the site. Otherwise, if you have sensitive data in your site's repository, you may want to remove the data before publishing. For more information, see "About repositories" and "Changing the visibility of your GitHub Pages site."

Publishing from a branch

  1. Make sure the branch you want to use as your publishing source already exists in your repository.

  2. GitHub Enterprise Cloudで、サイトのリポジトリにアクセスしてください。

  3. リポジトリ名の下で Settings(設定)をクリックしてください。 リポジトリの設定ボタン

  4. In the "Code and automation" section of the sidebar, click Pages.

  5. Under "Build and deployment", under "Source", select Deploy from a branch.

  6. Under "Build and deployment", under "Branch", use the None or Branch drop-down menu and select a publishing source.

    Drop-down menu to select a publishing source

  7. Optionally, use the drop-down menu to select a folder for your publishing source. Drop-down menu to select a folder for publishing source

  8. Click Save. Button to save changes to publishing source settings

Troubleshooting publishing from a branch

Note: If you are publishing from a branch and your site has not published automatically, make sure someone with admin permissions and a verified email address has pushed to the publishing source.

If you choose the docs folder on any branch as your publishing source, then later remove the /docs folder from that branch in your repository, your site won't build and you'll get a page build error message for a missing /docs folder. For more information, see "Troubleshooting Jekyll build errors for GitHub Pages sites."

Publishing with a custom GitHub Actions workflow

Note: Publishing your GitHub Pages site with a custom GitHub Actions workflow is in beta and subject to change.

To configure your site to publish with GitHub Actions:

  1. GitHub Enterprise Cloudで、サイトのリポジトリにアクセスしてください。

  2. リポジトリ名の下で Settings(設定)をクリックしてください。 リポジトリの設定ボタン

  3. In the "Code and automation" section of the sidebar, click Pages.

  4. Under "Build and deployment", under "Source", select GitHub Actions.

  5. GitHub Enterprise Cloud will suggest several starter workflows. If you already have a workflow to publish your site, you can skip this step. Otherwise, choose one of the options to create a GitHub Actions workflow. For more information about creating your custom workflow, see "Creating a custom GitHub Actions workflow to publish your site."

    GitHub Pages does not associate a specific workflow to the GitHub Pages settings. However, the GitHub Pages settings will link to the workflow run that most recently deployed your site.

Creating a custom GitHub Actions workflow to publish your site

For more information about GitHub Actions, see "Actions."

When you configure your site to publish with GitHub Actions, GitHub Enterprise Cloud will suggest starter workflows for common publishing scenarios. The general flow of a workflow is to:

  1. Trigger whenever there is a push to the default branch of the repository or whenever a pull request that targets the default branch is opened, reopened, or updated.
  2. Use the actions/checkout action to check out the repository contents.
  3. If required by your site, build any static site files.
  4. Use the actions/upload-pages-artifact action to upload the static files as an artifact.
  5. If the workflow was triggered by a push to the default branch, use the actions/deploy-pages action to deploy the artifact. This step is skipped if the workflow was triggered by a pull request.

The starter workflows use a deployment environment called github-pages. If your repository does not already include an environment called github-pages, the environment will be created automatically. We recommend that you add an environment protection rule so that only the default branch can deploy to this environment. For more information, see "Using environments for deployment."

Note: A CNAME file in your repository file does not automatically add or remove a custom domain. Instead, you must configure the custom domain through your repository settings or through the API. For more information, see "Managing a custom domain for your GitHub Pages site" and the Pages API reference documentation.

Troubleshooting publishing with a custom GitHub Actions workflow

For information about how to troubleshoot your GitHub Actions workflow, see "About monitoring and troubleshooting."