mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-23 08:57:35 +00:00
80 lines
2.8 KiB
YAML
80 lines
2.8 KiB
YAML
name: Documentation
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: "pages-${{ github.ref }}"
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
docs:
|
|
name: Build and Deploy Documentation
|
|
runs-on: ubuntu-latest
|
|
if: secrets.CLOUDFLARE_API_TOKEN != ''
|
|
|
|
steps:
|
|
- name: Sync repository
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
persist-credentials: false
|
|
fetch-depth: 0
|
|
|
|
- name: Detect runner environment
|
|
id: runner-env
|
|
uses: https://forgejo.ellis.link/continuwuation/detect-versions@d39555789fed25b8eb8e086d9f199c514dfa311e # v1
|
|
|
|
- name: Setup Node.js
|
|
if: steps.runner-env.outputs.node_major == '' || steps.runner-env.outputs.node_major < '20'
|
|
uses: https://github.com/actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
|
|
with:
|
|
node-version: 26
|
|
|
|
- name: Cache npm dependencies
|
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
|
with:
|
|
path: ~/.npm
|
|
key: continuwuity-rspress-${{ steps.runner-env.outputs.slug }}-${{ steps.runner-env.outputs.arch }}-node-${{ steps.runner-env.outputs.node_version }}-${{ hashFiles('package-lock.json') }}
|
|
restore-keys: |
|
|
continuwuity-rspress-${{ steps.runner-env.outputs.slug }}-${{ steps.runner-env.outputs.arch }}-node-${{ steps.runner-env.outputs.node_version }}-
|
|
continuwuity-rspress-${{ steps.runner-env.outputs.slug }}-${{ steps.runner-env.outputs.arch }}-node-
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build Rspress documentation
|
|
env:
|
|
SITE_PATH: ${{ github.ref != 'refs/heads/main' && format('/pr/{0}/', '${{ forgejo.event.number }}') || '/' }}
|
|
run: npm run docs:build
|
|
|
|
- name: Install Wrangler
|
|
run: npm install --save-dev wrangler@latest
|
|
|
|
- name: Deploy to Cloudflare Pages (Production)
|
|
if: github.ref == 'refs/heads/main' && vars.CLOUDFLARE_PROJECT_NAME != ''
|
|
uses: https://github.com/cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4
|
|
with:
|
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
command: pages deploy ./doc_build --branch="main" --commit-dirty=true --project-name="${{ vars.CLOUDFLARE_PROJECT_NAME }}"
|
|
|
|
- name: Deploy to Grebedoc (Preview)
|
|
if: github.ref != 'refs/heads/main'
|
|
uses: actions/git-pages@v2
|
|
with:
|
|
site: https://preview.continuwuity.org
|
|
path: "pr/${{ forgejo.event.number }}"
|
|
server: grebedoc.dev
|
|
token: ${{ forgejo.token }}
|
|
source: doc_build/
|
|
strict: true
|
|
pretty-urls: true
|
|
expires: 14
|
|
comment: ${{ forgejo.sha }}
|