GitHub Actions Setup
GitHub Actions Setup Guide
Overview
This guide covers the workflow that builds this documentation with Hugo and publishes it to GitHub Pages. The application’s own checks are in a separate workflow, described in CI/CD Pipeline.
Workflow Architecture
Workflow File
Location: .github/workflows/docs.yml
Triggers:
- A push to
mainthat changes anything underdocs/or the workflow file itself - A manual run (
workflow_dispatch)
Two Pipeline Jobs
Job 1: Build Hugo Documentation
What it does:
- Checks out the repository (the theme is vendored in
docs/themes/, so no submodules are needed) - Installs Hugo, pinned to 0.141.0 extended (the Relearn theme needs the extended build)
- Builds the site into
docs/public/ - Uploads it as a Pages artifact
Job 2: Deploy to GitHub Pages
It only runs when the build succeeds and publishes the artifact. The live URL appears on the workflow run and the github-pages environment.
Enabling GitHub Pages
Required Configuration
GitHub Pages must be set to deploy from GitHub Actions. Without this, the deploy job fails with a permissions or “Pages not enabled” error.
Step-by-Step Setup
- Open your repository on GitHub
- Go to Settings → Pages
- Under Build and deployment → Source, choose GitHub Actions
- Push a change under
docs/tomain(or run the workflow manually from the Actions tab) - Wait for both jobs to turn green
Your Documentation URL
For this project: https://karmen87.github.io/Crypto_Alarm/. The baseURL in docs/hugo.toml must match it, or CSS and links will break.
Workflow Permissions
contents: read: check out the codepages: write: publish to Pagesid-token: write: letsdeploy-pagesverify the deployment source
Concurrency Control
Only one Pages deployment runs at a time. A second push waits instead of cancelling a deployment that is already in flight.
Manual Triggering
- Open the Actions tab
- Select the Docs workflow
- Click Run workflow and choose
main
Useful after changing the Pages settings, or to rebuild without a docs change.
Monitoring Workflow Runs
Viewing Logs
- Actions tab → select the run
- Open the
buildordeployjob - Expand a step to read its output
Common Log Sections
- Setup Hugo: shows the Hugo version that was installed
- Build site: Hugo’s page and build statistics; warnings about missing shortcodes or references appear here
- Upload artifact: size of the generated site
Troubleshooting
Workflow Does Not Start
Cause: the push did not touch docs/ or the workflow file.
Solution: change a file under docs/, or run the workflow manually.
Workflow Fails on Build Job
Hugo build errors
Reproduce locally with the same version:
Typical causes:
- A shortcode that is not closed (a
noticeblock without its closing tag) - A
relrefpointing at a page that does not exist - Front matter YAML errors (bad indentation or quoting)
Site Loads Without Styling
Cause: baseURL in docs/hugo.toml does not match the Pages URL.
Solution: set it to https://<username>.github.io/<repository>/ (with the trailing slash).
Workflow Fails on Deploy Job
Cause: Pages source is not set to GitHub Actions, or the workflow lacks pages: write / id-token: write.
Solution: fix the setting under Enabling GitHub Pages and re-run the workflow.
Workflow Performance
Typical Run Times
| Job | Typical time |
|---|---|
| build | about 30-60 seconds (a tiny site, most time goes to downloading Hugo) |
| deploy | about 10-30 seconds |
Optimization Tips
The workflow already skips runs that don’t touch the documentation, through its paths filter.
Cost & Usage
GitHub Actions and Pages are free for public repositories. The docs workflow is short and only runs when documentation changes.
Adding Status Badge
Security Considerations
Secrets Management
The workflow needs no secrets: it uses the built-in short-lived GITHUB_TOKEN and OIDC token only.
Dependency Security
- Actions are pinned to major versions (
@v4,@v3) - Hugo is pinned to an exact version
- The theme is vendored and changes only through reviewed commits
Custom Domain (Optional)
- In Settings → Pages, enter your domain under Custom domain
- Create a
CNAMEDNS record pointing to<username>.github.io - Update
baseURLindocs/hugo.tomlto your domain - Enable Enforce HTTPS once the certificate is issued
Next Steps
- See CI/CD Pipeline for the application’s own CI workflow and Docker setup