Skip to content

fix: update markdown code block syntax for template directives to ens… #6

fix: update markdown code block syntax for template directives to ens…

fix: update markdown code block syntax for template directives to ens… #6

name: Release and Deploy Docs
# Workflow triggers
on:
# Trigger on pushes to main branch
push:
branches:
- main
# Allow manual workflow dispatch
workflow_dispatch:
# Set permissions for GitHub token
permissions:
contents: write
pages: write
id-token: write
packages: write
# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: false
# Environment variables
env:
NODE_VERSION: '22'
PNPM_VERSION: '9'
jobs:
# Release job
release:
name: Release to npm
runs-on: ubuntu-latest
steps:
# Step 1: Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for git info
# Step 2: Setup pnpm
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
run_install: false
# Step 3: Setup Node.js with pnpm cache
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
# Step 4: Get pnpm store directory for caching
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "store-path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
# Step 5: Setup pnpm cache
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.store-path }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# Step 6: Setup Turborepo cache
- name: Setup Turborepo cache
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
# Step 7: Install dependencies
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
HUSKY: 0 # Disable Husky hooks during CI
# Step: Create Release Pull Request or Publish to npm
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: pnpm run release
version: pnpm run version-packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
# Build docs job
build-docs:
name: Build Docusaurus Site
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || contains(github.event.paths, 'apps/docs/**') || contains(github.event.paths, 'package.json') || contains(github.event.paths, 'pnpm-lock.yaml')
steps:
# Step 1: Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for git info
# Step 2: Setup pnpm
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
run_install: false
# Step 3: Setup Node.js with pnpm cache
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
# Step 4: Get pnpm store directory for caching
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "store-path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
# Step 5: Setup pnpm cache
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.store-path }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# Step 6: Setup Turborepo cache
- name: Setup Turborepo cache
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
# Step 7: Install dependencies
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
HUSKY: 0 # Disable Husky hooks during CI
# Step 8: Build Docusaurus site
- name: Build Docusaurus site
run: pnpm --filter @petk/docs build
env:
NODE_ENV: production
# GitHub Pages specific configurations
DOCUSAURUS_URL: https://petk.dev
DOCUSAURUS_BASE_URL: /
# Step 9: Setup Pages
- name: Setup GitHub Pages
uses: actions/configure-pages@v5
# Step 10: Upload build artifacts
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./apps/docs/build
# Deploy job
deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
needs: build-docs
if: always() && needs.build-docs.result == 'success'
steps:
# Deploy to GitHub Pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# Optional: Add status check job for PR protection
status-check:
name: Documentation Build Status
runs-on: ubuntu-latest
needs: [build-docs, deploy]
if: always()
steps:
- name: Check deployment status
run: |
if [ "${{ needs.build-docs.result }}" == "skipped" ]; then
echo "No docs changes, skipping deployment check"
exit 0
fi
if [ "${{ needs.build-docs.result }}" == "success" ] && [ "${{ needs.deploy.result }}" == "success" ]; then
echo "✅ Documentation successfully deployed to GitHub Pages"
echo "📍 URL: https://petk.dev/"
exit 0
else
echo "❌ Documentation deployment failed"
echo "Build status: ${{ needs.build-docs.result }}"
echo "Deploy status: ${{ needs.deploy.result }}"
exit 1
fi
# Workflow metadata for status badges
# To add a status badge to your README:
# [![Release and Deploy Docs](https://github.com/mihazs/petk/actions/workflows/release-and-deploy-docs.yml/badge.svg)](https://github.com/mihazs/petk/actions/workflows/release-and-deploy-docs.yml)