Files

106 lines
2.8 KiB
YAML

name: Docs
on:
push:
tags:
- "v*"
branches:
- "main"
- "release/docs"
concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
beta:
name: Deploy Beta Docs
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: package.json
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build docs
run: pnpm docs:build
env:
HEADPLANE_BETA_DOCS: "true"
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
command: pages deploy docs/.vitepress/dist --project-name=headplane-docs-beta
channel:
name: Release Channel
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.check.outputs.latest }}
steps:
# Patch releases on older lines must not replace the stable docs.
- name: Check if this is the newest stable release
id: check
env:
TAG: ${{ github.ref_name }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
run: |
NEWEST=$(git ls-remote --tags --refs "$REPO_URL" 'v*' \
| sed 's|.*refs/tags/||' | grep -v -- - | sort -V | tail -n 1)
[[ "$TAG" == "$NEWEST" ]] && LATEST=true || LATEST=false
echo "Newest stable release is $NEWEST, latest=$LATEST"
echo "latest=$LATEST" >> "$GITHUB_OUTPUT"
stable:
name: Deploy Stable Docs
needs: channel
if: >
!cancelled()
&& (needs.channel.outputs.latest == 'true' || github.ref == 'refs/heads/release/docs')
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: package.json
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build docs
run: pnpm docs:build
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
command: pages deploy docs/.vitepress/dist --project-name=headplane-docs