feat: update GH action

Base on Hugo docs and hugo paperMod them
This commit is contained in:
2025-09-28 09:48:38 +07:00
parent 8965df427d
commit cb6fb4589f
+59 -35
View File
@@ -1,89 +1,114 @@
name: Deploy Hugo site to Pages
name: Build and deploy
on:
push:
branches:
- main
workflow_dispatch:
inputs:
hugoVersion:
description: "Hugo Version"
required: false
default: "0.140.2"
permissions:
contents: read
pages: write
id-token: write
deployments: write
concurrency:
group: "pages"
group: pages
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
name: Build
env:
HUGO_VERSION: 0.140.2
HUGO_ENVIRONMENT: production
DART_SASS_VERSION: 1.83.0
GO_VERSION: 1.23.4
HUGO_VERSION: ${{ github.event.inputs.hugoVersion || '0.140.2' }}
NODE_VERSION: 22.12.0
TZ: Asia/Ho_Chi_Minh
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: recursive
fetch-depth: 0
- name: Cache Restore
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Create directory for user-specific executable files
run: |
mkdir -p "${HOME}/.local"
- name: Install Dart Sass
run: |
curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz"
echo "${HOME}/.local/dart-sass" >> "${GITHUB_PATH}"
- name: Install Hugo
run: |
curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
mkdir "${HOME}/.local/hugo"
tar -C "${HOME}/.local/hugo" -xf "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
rm "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
echo "${HOME}/.local/hugo" >> "${GITHUB_PATH}"
- name: Verify installations
run: |
echo "Dart Sass: $(sass --version)"
echo "Go: $(go version)"
echo "Hugo: $(hugo version)"
echo "Node.js: $(node --version)"
- name: Install Node.js dependencies
run: |
[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true
- name: Configure Git
run: |
git config core.quotepath false
- name: Cache restore
id: cache-restore
uses: actions/cache/restore@v4
with:
path: |
${{ runner.temp }}/hugo_cache
path: ${{ runner.temp }}/hugo_cache
key: hugo-${{ github.run_id }}
restore-keys:
hugo-
- name: Configure Git
run: git config core.quotepath false
- name: Build with Hugo
restore-keys: hugo-
- name: Build the site
run: |
hugo \
--gc \
--minify \
--baseURL "https://miti99.com/" \
--cacheDir "${{ runner.temp }}/hugo_cache"
- name: Cache Save
- name: Cache save
id: cache-save
uses: actions/cache/save@v4
with:
path: |
${{ runner.temp }}/hugo_cache
path: ${{ runner.temp }}/hugo_cache
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./public
deploy-github:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
name: Deploy to GitHub Pages
needs: build
steps:
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
deploy-cloudflare:
runs-on: ubuntu-latest
name: Deploy to CloudFlare Pages
@@ -105,7 +130,6 @@ jobs:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy ./public --project-name=miti99
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
submit-indexnow:
runs-on: ubuntu-latest
name: Check and submit to IndexNow