mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-13 20:14:15 +00:00
- Refactor build into reusable workflow (DRY) - Add deploy.host config to control deployment target - Upgrade to latest action versions (Node 22, Go 1.23, Python 3.13) - Add timeout-minutes and concurrency groups for safety - Use github.run_id for unique PR branch names - Fix package_json_path for standalone repo compatibility - Scope GITHUB_TOKEN to specific steps for security
67 lines
2.0 KiB
YAML
67 lines
2.0 KiB
YAML
name: Deploy website to GitHub Pages
|
|
|
|
on:
|
|
# Trigger the workflow every time you push to the `main` branch
|
|
push:
|
|
branches: ['main']
|
|
# Allows you to run this workflow manually from the Actions tab on GitHub
|
|
workflow_dispatch:
|
|
|
|
# Provide permission to clone the repo and deploy it to GitHub Pages
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
concurrency:
|
|
group: 'pages'
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
# Check deployment configuration
|
|
config:
|
|
if: github.repository_owner != 'HugoBlox'
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
deploy-host: ${{ steps.check.outputs.host }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
sparse-checkout: hugoblox.yaml
|
|
sparse-checkout-cone-mode: false
|
|
|
|
- name: Check deploy host
|
|
id: check
|
|
run: |
|
|
# Read deploy.host from hugoblox.yaml, default to github-pages
|
|
HOST=$(grep -A5 "^deploy:" hugoblox.yaml 2>/dev/null | grep "host:" | awk '{print $2}' | tr -d "'\""" || echo "github-pages")
|
|
HOST=${HOST:-github-pages}
|
|
echo "host=$HOST" >> $GITHUB_OUTPUT
|
|
echo "Deployment target: $HOST"
|
|
|
|
# Build website using reusable workflow (always runs for CI)
|
|
build:
|
|
needs: config
|
|
if: github.repository_owner != 'HugoBlox'
|
|
uses: ./.github/workflows/build.yml
|
|
secrets: inherit
|
|
|
|
# Deploy website to GitHub Pages hosting (only if configured)
|
|
deploy:
|
|
needs: [config, build]
|
|
if: needs.config.outputs.deploy-host == 'github-pages'
|
|
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
|
|
permissions:
|
|
pages: write # to deploy to Pages
|
|
id-token: write # to verify the deployment originates from an appropriate source
|
|
# Deploy to the github-pages environment
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v4
|