Deploy to GitHub Pages
This guide explains how to deploy a multilingual static site generated by CZON to GitHub Pages using GitHub CLI.
First, install the GitHub CLI tool (if not already installed) and ensure you are logged in (if not already logged in):
$ gh --version # Check the version to ensure successful installation
Ensure you are logged in and have repo access permissions to the target repository:
$ gh auth login -s repo # Log in to your GitHub account; you will be prompted to log in via browser or use a token
$ gh auth status # Check login status to ensure you are successfully logged in and have repo access permissions to the target repository
After that, simply run the following command and follow the prompts:
$ npx czon@latest config github
This command will guide you through the following steps:
- Check if gh permissions include
repo. If not, you will be prompted to log in again and addrepopermissions. - If the local directory is not a Git repository, you will be prompted to initialize a new Git repository.
- Check the remote Git repository settings of the local directory to see if there is a GitHub remote repository. If there is no GitHub remote repository, you will be prompted to create a new remote repository and add it as the remote
origin. Iforiginalready exists but is not a GitHub repository, you will be prompted to add a new GitHub remote repository asupstream. - Check if GitHub Pages is enabled and is of the workflow type. If not, enable it via the API
gh apiand correct it to deploy from Actions. Also, set up the CNAME (if you have a custom domain). - Check the GitHub Workflow file. If it has not been created, create the Pages Workflow file; if it already exists but is not the latest version, you will be prompted to update the Workflow file.
- Commit the Workflow file and push the changes to the remote repository.
- Prompt you to visit the GitHub Pages website URL, retrieving the latest Pages URL via
gh api.