Files
miti99/.github/workflows/hugo.yml
T
2025-05-09 01:31:48 +07:00

119 lines
3.0 KiB
YAML

name: Deploy Hugo site to Pages
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
deployments: write
concurrency:
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
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
with:
submodules: recursive
fetch-depth: 0
- name: Cache Restore
id: cache-restore
uses: actions/cache/restore@v4
with:
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
run: |
hugo \
--gc \
--minify \
--baseURL "https://miti99.com/" \
--cacheDir "${{ runner.temp }}/hugo_cache"
- name: Cache Save
id: cache-save
uses: actions/cache/save@v4
with:
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:
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
needs: build
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: github-pages
path: .
- name: Extract artifact
run: |
mkdir -p public
tar -xf artifact.tar -C public
- name: Deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
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
needs: deploy-cloudflare
steps:
- name: indexnow-action
uses: bojieyang/indexnow-action@v2
with:
sitemap-location: 'https://miti99.com/sitemap.xml'
key: ${{ secrets.INDEXNOW_KEY }}