Skip to content

contents-update

contents-update #144

name: Build & Deploy
on:
workflow_dispatch:
repository_dispatch:
types:
- contents-update
- contents-issues-update
push:
branches:
- v4
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:
prepare:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout Contents
uses: actions/checkout@v3
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@v2
with:
path: ./${{ env.BUILD_OUTPUT_DIR_MAIN }}
# deploy:
# runs-on: ubuntu-latest
# needs: prepare
# env:
# BUILD_OUTPUT_DIR: "dist"
# steps:
# - name: Donwload Artifact
# uses: actions/download-artifact@v3
# with:
# name: blog-build-main
# path: ./${{ env.BUILD_OUTPUT_DIR_MAIN }}
#
# - name: Deploy Server
# uses: burnett01/[email protected]
# with:
# switches: -avzr --delete
# path: ${{ env.BUILD_OUTPUT_DIR_MAIN }}/.
# remote_path: ${{ secrets.MIRROR_TARGET }}
# remote_host: ${{ secrets.MIRROR_HOST }}
# remote_user: github
# remote_key: ${{ secrets.MIRROR_SSH_PRIVATE_KEY }}
deploy-gh-pages:
runs-on: ubuntu-latest
needs: prepare
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2