Add translatable "On this page" title to desktop table of contents (#… #68
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to Production | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: "Deployment environment" | |
| required: false | |
| default: "production" | |
| type: choice | |
| options: | |
| - production | |
| - test | |
| branch_name: | |
| description: "Branch name for test deployment (only used if environment=test)" | |
| required: false | |
| default: "test" | |
| type: string | |
| repository_dispatch: | |
| types: [deploy-production] | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - "**.md" | |
| - "docs/**" | |
| jobs: | |
| deploy: | |
| name: Deploy to Cloudflare Pages and Update Notion | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code (main branch) | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Checkout content files from content branch | |
| run: | | |
| set -e # Exit on error | |
| echo "📥 Fetching content from content branch..." | |
| git fetch origin content | |
| echo "📂 Checking out content files..." | |
| git checkout origin/content -- docs/ i18n/ static/images/ | |
| # Validate content exists | |
| echo "🔍 Validating content..." | |
| # Count markdown files across all languages | |
| # Guard against missing directories to avoid find failures | |
| # Support both .md and .mdx files (Docusaurus accepts both) | |
| if [ -d docs ]; then | |
| DOCS_COUNT=$(find docs \( -name "*.md" -o -name "*.mdx" \) -type f 2>/dev/null | wc -l) | |
| else | |
| DOCS_COUNT=0 | |
| fi | |
| if [ -d i18n ]; then | |
| I18N_COUNT=$(find i18n \( -name "*.md" -o -name "*.mdx" \) -type f 2>/dev/null | wc -l) | |
| else | |
| I18N_COUNT=0 | |
| fi | |
| TOTAL_CONTENT=$((DOCS_COUNT + I18N_COUNT)) | |
| if [ "$TOTAL_CONTENT" -eq 0 ]; then | |
| echo "❌ Error: No documentation content found" | |
| echo " Expected: At least one .md or .mdx file in docs/ or i18n/ directories" | |
| echo " Found: 0 files" | |
| echo "Cannot proceed with build - documentation content is required" | |
| exit 1 | |
| fi | |
| # Warn if default locale (English) has no content | |
| if [ "$DOCS_COUNT" -eq 0 ]; then | |
| echo "⚠️ WARNING: No English content in docs/ directory" | |
| echo " Docusaurus build may fail if default locale has no content" | |
| fi | |
| if [ ! -d "static/images" ] || [ -z "$(ls -A static/images 2>/dev/null)" ]; then | |
| echo "⚠️ Warning: static/images/ directory is empty or missing" | |
| echo "Build will proceed but images may be unavailable" | |
| fi | |
| echo "✅ Content validation successful" | |
| echo "📊 Content statistics:" | |
| echo " - English docs: $DOCS_COUNT" | |
| echo " - Localized docs: $I18N_COUNT" | |
| echo " - Total docs: $TOTAL_CONTENT" | |
| find static/images -type f 2>/dev/null | wc -l | xargs echo " - Images:" | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Build documentation | |
| run: bun run build | |
| - name: Deploy to Cloudflare Pages | |
| id: deploy | |
| uses: cloudflare/wrangler-action@v3 | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| command: >- | |
| pages deploy build --project-name comapeo-docs | |
| ${{ inputs.environment == 'test' && format('--branch {0}', inputs.branch_name) || '' }} | |
| ${{ inputs.environment == 'test' && '--commit-dirty=true' || '' }} | |
| - name: Update Notion status to Published | |
| if: inputs.environment != 'test' | |
| run: bun run notionStatus:publish-production | |
| env: | |
| NOTION_API_KEY: ${{ secrets.NOTION_API_KEY }} | |
| DATA_SOURCE_ID: ${{ secrets.DATA_SOURCE_ID }} | |
| DATABASE_ID: ${{ secrets.DATABASE_ID }} | |
| - name: Deployment summary | |
| run: | | |
| if [ "${{ inputs.environment }}" = "test" ]; then | |
| BRANCH_NAME="${{ inputs.branch_name }}" | |
| echo "🧪 **Test Deployment Complete!**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Documentation built successfully" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Deployed to Cloudflare Pages (test)" >> $GITHUB_STEP_SUMMARY | |
| echo "- 🌐 Test URL: https://${BRANCH_NAME}.comapeo-docs.pages.dev" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Note**: This is a test deployment. Notion status not updated." >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "🚀 **Production Deployment Complete!**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Documentation built successfully" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Deployed to Cloudflare Pages" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Notion status updated: Staging → Published" >> $GITHUB_STEP_SUMMARY | |
| echo "- 📅 Published date set to $(date -u +%Y-%m-%d)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "🌐 Site available at: https://docs.comapeo.app" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| - name: Notify Slack | |
| if: always() | |
| uses: slackapi/[email protected] | |
| with: | |
| webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| webhook-type: incoming-webhook | |
| payload: | | |
| text: "*Deploy to Cloudflare Pages*: ${{ job.status }}" | |
| blocks: | |
| - type: "section" | |
| text: | |
| type: "mrkdwn" | |
| text: "*Deploy to Cloudflare Pages*: ${{ job.status }}\nEnvironment: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || github.event_name == 'repository_dispatch' && 'production' || 'production' }}" | |
| - type: "section" | |
| text: | |
| type: "mrkdwn" | |
| text: "Trigger: <https://github.com/${{ github.triggering_actor }}|${{ github.triggering_actor }}>\nDetails: ${{ github.event_name == 'pull_request' && github.event.pull_request.html_url || github.event.head_commit.url || format('{0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id) }}" | |
| - type: "section" | |
| text: | |
| type: "mrkdwn" | |
| text: "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'test' && format('Preview URL: https://{0}.comapeo-docs.pages.dev', github.event.inputs.branch_name) || 'Production URL: https://docs.comapeo.app' }}" |