Skip to content

Cloudflare Pages #11044

Cloudflare Pages

Cloudflare Pages #11044

name: Cloudflare Pages
on:
push:
schedule:
- cron: '0 * * * *'
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Publish to Cloudflare Pages
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Cache resources
uses: actions/cache@v3
with:
path: ./resources
key: hugo-resources
- name: Cache Hugo modules
uses: actions/cache@v3
with:
path: /tmp/hugo_cache
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-hugomod-
- name: Build
uses: addnab/docker-run-action@v3
with:
image: hugomods/hugo:exts
options: >-
-v ${{ github.workspace }}:/src
-v /tmp/hugo_cache:/tmp/hugo_cache
-e GITHUB_TOKEN
-e NETRC_USERNAME
-e NETRC_PASSWORD
run: >-
echo "machine github.com" >> $HOME/.netrc &&
echo "login ${NETRC_USERNAME}" >> $HOME/.netrc &&
echo "password ${NETRC_PASSWORD}" >> $HOME/.netrc &&
hugo --minify --gc --enableGitInfo &&
cp public/en/404.html public/404.html
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NETRC_USERNAME: ${{ secrets.NETRC_GITHUB_USERNAME }}
NETRC_PASSWORD: ${{ secrets.NETRC_GITHUB_PASSWORD }}
- name: Publish English Site to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: hbstack
directory: ./public/en
# Optional: Enable this if you want to have GitHub Deployments triggered
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Simplified Chinese to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: hbstack-zh-hans
directory: ./public/zh-hans
# Optional: Enable this if you want to have GitHub Deployments triggered
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Traditional Chinese Site to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: hbstack-zh-hant
directory: ./public/zh-hant
# Optional: Enable this if you want to have GitHub Deployments triggered
gitHubToken: ${{ secrets.GITHUB_TOKEN }}