Skip to content

Merge pull request #404 from auth0/fix/publish-workflow-remove-npm-up… #171

Merge pull request #404 from auth0/fix/publish-workflow-remove-npm-up…

Merge pull request #404 from auth0/fix/publish-workflow-remove-npm-up… #171

Workflow file for this run

name: Generate API Documentation
on:
# Manual trigger for testing
workflow_dispatch:
inputs:
target_branch:
description: "Branch to generate docs from (defaults to main)"
required: false
type: string
default: "main"
# Trigger on push to main for testing
push:
branches:
- 'main'
# Automatically trigger after successful npm publish
workflow_run:
workflows: ["Publish to Public NPM"]
types: [completed]
branches: [main]
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
generate-docs:
name: Generate API Docs
runs-on: ubuntu-latest
# Only run if manually triggered, push event, OR if publish workflow succeeded
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Determine target branch
id: branch
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_TARGET_BRANCH: ${{ inputs.target_branch }}
REF_NAME: ${{ github.ref_name }}
run: |
if [ "${EVENT_NAME}" == "workflow_dispatch" ]; then
BRANCH="${INPUT_TARGET_BRANCH}"
elif [ "${EVENT_NAME}" == "push" ]; then
BRANCH="${REF_NAME}"
else
BRANCH="main"
fi
echo "branch=${BRANCH:-main}" >> $GITHUB_OUTPUT
echo "Using branch: ${BRANCH:-main}"
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
ref: ${{ steps.branch.outputs.branch }}
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
with:
version: 10.6.5
- name: Setup Node.js
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4
with:
node-version: "22"
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build packages
run: pnpm run build
- name: Generate API documentation
run: pnpm docs:api
- name: Setup GitHub Pages
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
with:
path: docs-api
- name: Generate Summary
env:
TARGET_BRANCH: ${{ steps.branch.outputs.branch }}
EVENT_NAME: ${{ github.event_name }}
run: |
echo "## 📚 API Documentation Generated" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Branch:** \`${TARGET_BRANCH}\`" >> $GITHUB_STEP_SUMMARY
echo "**Trigger:** \`${EVENT_NAME}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Generated Files" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
find docs-api -type f | head -30 >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📦 Artifact uploaded, proceeding to deploy..." >> $GITHUB_STEP_SUMMARY
deploy-docs:
name: Deploy to GitHub Pages
needs: generate-docs
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4
- name: Generate Deployment Summary
env:
PAGE_URL: ${{ steps.deployment.outputs.page_url }}
run: |
echo "## 🚀 API Documentation Deployed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**URL:** ${PAGE_URL}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The API documentation is now live at:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "🔗 **https://auth0.github.io/auth0-ui-components/**" >> $GITHUB_STEP_SUMMARY