Skip to content

Deploy docs and demo to gh-pages #89

Deploy docs and demo to gh-pages

Deploy docs and demo to gh-pages #89

Workflow file for this run

name: Deploy docs and demo to gh-pages
on:
push:
branches: ["main"]
tags:
- "v*.*.*"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: gh-pages-deploy
cancel-in-progress: false
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.8.0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Verify build requirements
run: |
# Check if required scripts exist
if [ ! -f "./scripts/docs/generate-doc-versions-json.sh" ]; then
echo "Error: generate-doc-versions-json.sh not found"
exit 1
fi
# Make script executable
chmod +x ./scripts/docs/generate-doc-versions-json.sh
- name: Build TypeDoc
run: pnpm run docs:build
- name: Generate versions.json (latest + tags)
run: |
bash ./scripts/docs/generate-doc-versions-json.sh docs "https://vintasoftware.github.io/kill-the-clipboard"
# Verify the required directories were created
if [ ! -d "docs-root" ]; then
echo "Error: docs-root directory was not created"
exit 1
fi
if [ ! -f "docs/versions.json" ]; then
echo "Error: versions.json was not created"
exit 1
fi
# Build demo/shc only for main branch
- name: Build library (for demo/shc)
if: github.ref == 'refs/heads/main'
run: pnpm run build
- name: Install demo/shc dependencies
if: github.ref == 'refs/heads/main'
run: |
cd demo/shc
pnpm install --frozen-lockfile
- name: Build demo/shc (Vite)
if: github.ref == 'refs/heads/main'
run: |
cd demo/shc
pnpm build
- name: Deploy to gh-pages (root redirect)
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: docs-root
keep_files: true
- name: Deploy to gh-pages (latest/)
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: docs
destination_dir: latest
keep_files: true
- name: Resolve ref name (tag)
if: startsWith(github.ref, 'refs/tags/v')
id: ref
run: |
REF=${GITHUB_REF_NAME}
echo "ref_name=${REF}" >> $GITHUB_OUTPUT
- name: Deploy to gh-pages (vX.Y.Z/)
if: startsWith(github.ref, 'refs/tags/v')
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: docs
destination_dir: ${{ steps.ref.outputs.ref_name }}
keep_files: true
- name: Deploy to gh-pages (demo/shc/)
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: demo/shc/dist
destination_dir: demo/shc
keep_files: true