This repository contains a GitHub Actions workflow that automates the deployment of static content to GitHub Pages. This guide explains how the workflow is configured and how to use it.
The workflow file .github/workflows/deploy.yml
automates the deployment of static content to GitHub Pages whenever there are changes pushed to the main
branch or when the workflow is manually triggered.
- Automatic Deployment: Deploys static content automatically on every push to the
main
branch. - Manual Deployment: Allows manual triggering of deployments via the GitHub Actions tab.
- Concurrency Control: Ensures only one deployment runs at a time to avoid conflicts while allowing ongoing deployments to complete.
- Secure Permissions: Utilizes
GITHUB_TOKEN
with restricted permissions to securely deploy content.
- Ensure your repository is public or has GitHub Pages enabled.
- Configure GitHub Pages in the repository settings to use the
gh-pages
branch.
Here is a breakdown of the workflow steps:
- push: The workflow triggers on pushes to the
main
branch. - workflow_dispatch: The workflow can be manually triggered from the Actions tab.
The workflow sets permissions for the GITHUB_TOKEN
to:
contents: read
pages: write
id-token: write
- The workflow ensures only one deployment runs at a time for the
pages
group. cancel-in-progress: false
allows in-progress deployments to complete.
The deploy
job performs the deployment:
- name:
github-pages
- url: Automatically set to the deployed GitHub Pages URL.
- Checkout Repository:
Uses
actions/checkout@v4
to clone the repository. - Setup Pages:
Uses
actions/configure-pages@v5
to configure the GitHub Pages environment. - Upload Artifact:
Uses
actions/upload-pages-artifact@v3
to upload the static content. The entire repository is uploaded by settingpath: '.'
. - Deploy to GitHub Pages:
Uses
actions/deploy-pages@v4
to deploy the content. The deployed URL is stored in thepage_url
output variable.
- Push changes to the
main
branch, and the workflow will automatically deploy the content to GitHub Pages. - Alternatively, navigate to the Actions tab in your repository, select the workflow, and trigger it manually using the "Run workflow" button.
This project is part of Janis Adhikari's DevOps projects.