This is an example how to build and deploy to GitHub Pages using GitHub Actions (CI.yml). The build step is run on every branch, but the deploy step is run only on the main branch.
Prerequisite: the root folder of the gh-pages branch must be set as source in the GitHub Pages section on the Settings tab of the repository.
The results can be found here: BuildAndDeployToGitHubPages