Skip to content

Back to scoped styling and CSS vars #350

Back to scoped styling and CSS vars

Back to scoped styling and CSS vars #350

name: Deploy to web
on:
push:
branches:
- main
env:
HUGO_VERSION: 0.118.2 # will get Extended Version below
HUGO_NPM: false # choices: 'true' and 'false' (mainly checking only for [== "true"])
# ^^ refers to whether we're using the npm pkg `hugo-installer`
DART_SASS_VERSION: 1.66.1 # (depends on STYLING env var)
NODE: false # choices: 'true' and 'false' (mainly checking only for [== "true"])
NODE_VERSION: 18 # (18.16.0 = CFP v2 build image default as of 2023-05-17)
# ^^ https://developers.cloudflare.com/pages/platform/language-support-and-tools/
STYLING: SCSS # 'SCSS' or 'VCSS'; 'VCSS' requires PostCSS as of 2023-09-04
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- name: Set GHA runner TZ to U.S. Central time
uses: szenius/set-timezone@v1.2
with:
timezoneLinux: "America/Chicago" # default = "UTC"
- name: Checkout default branch
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Node.js (cond. - Node)
if: ${{ env.NODE == 'true' }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install npm packages (cond. - Node)
if: ${{ env.NODE == 'true' || env.STYLING == 'VCSS' }}
run: npm install
- name: Hugo download/install (cond. - non-Hugo-via-hugo-installer)
if: ${{ env.HUGO_NPM != 'true' }}
run: |
wget https://github.com/gohugoio/hugo/releases/download/v${{ env.HUGO_VERSION }}/hugo_extended_${{ env.HUGO_VERSION }}_linux-amd64.deb -O hugo_extended_${{ env.HUGO_VERSION }}_linux-amd64.deb
sudo dpkg -i hugo*.deb
- name: Install Dart Sass (cond. - SCSS)
if: ${{ env.STYLING == 'SCSS' }}
run: |
curl -LJO https://github.com/sass/dart-sass/releases/download/${{ env.DART_SASS_VERSION }}/dart-sass-${{ env.DART_SASS_VERSION }}-linux-x64.tar.gz
tar -xvf dart-sass-${{ env.DART_SASS_VERSION }}-linux-x64.tar.gz
dart-sass/sass --embedded --version
echo "$GITHUB_WORKSPACE/dart-sass" >> $GITHUB_PATH
- name: Cache appropriate Hugo items
id: cache-hugosite
uses: actions/cache@v3
with:
path: |
resources
static
key: ${{ runner.os }}-hugosite
- name: Build site with Hugo, move feed files, run Pagefind (cond. - Node)
if: ${{ env.HUGO_NPM == 'true' }}
run: npm run build
- name: Build site with Hugo, move feed files, run Pagefind (cond. - non-Node)
if: ${{ env.HUGO_NPM != 'true' }}
run: |
hugo --gc --minify --logLevel info
mv public/posts/index.xml public/index-excerpts.xml
mv public/posts/index.json public/index-excerpts.json
npm_config_yes=true npx pagefind@latest --source "public"
- name: Publish to CFP
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CFP_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
projectName: 'static-site-v2' # was 'static-site'
directory: 'public'
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
# To do a push without triggering this GHA, include one of
# the following in the **commit message**
# (INCLUDING the brackets AND case-sensitivity):
#
# [skip ci] (works also in CFP GUI)
# [ci skip] (works also in CFP GUI)
# [no ci]
# [skip actions]
# [actions skip]
#
# “Alternatively, you can end the commit message
# with two empty lines followed by either
# `skip-checks: true` or `skip-checks:true`.”
#
# ref: https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs
#
# --------
# For CFP GUI only, it's (case-**in**sensitive):
# [CI Skip]
# [CI-Skip]
# [Skip CI] <-- This is the one we can use on all, albeit as `[skip ci]`
# [Skip-CI]
# [CF-Pages-Skip]
# ref: https://developers.cloudflare.com/pages/platform/branch-build-controls/
# --------