Skip to content

4.6.2

4.6.2 #189

name: Build & Deploy
on:
workflow_dispatch:
repository_dispatch:
types:
- contents-update
- contents-issues-update
push:
branches:
- main
tags:
- "v*"
concurrency:
group: "build"
cancel-in-progress: true
permissions:
contents: read
env:
# envs for build
PUBLIC_BUILT_BY: "ci" # Build indicator on the blog
POSTS_DIR: "data/posts" # fs content provider
GITHUB_USER: "Yixuan-Wang" # GitHub content provider (username)
GITHUB_REPO: "blog-contents" # GitHub content provider (repo)
GITHUB_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # GitHub content provider (access token)
# build outputs
BUILD_OUTPUT_DIR_MAIN: "dist" # Build output directory for main site
jobs:
cloudflare-pages:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout Contents
uses: actions/checkout@v4
with:
repository: Yixuan-Wang/blog-contents
ref: v4
path: data
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Setup `pnpm`
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Cache `pnpm` Modules
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Node Packages
run: pnpm install
- name: Build
env:
PUBLIC_BUILD_SITE_URL: "https://blog.yixuan-wang.site"
PUBLIC_BUILD_BASE_URL: "/"
run: pnpm run build -- --outDir=${{ env.BUILD_OUTPUT_DIR_MAIN }}
- name: Upload Pages Artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./${{ env.BUILD_OUTPUT_DIR_MAIN }}
- name: Publish to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy ${{ env.BUILD_OUTPUT_DIR_MAIN }} --project-name=blog