-
Notifications
You must be signed in to change notification settings - Fork 6
139 lines (117 loc) · 4.27 KB
/
Copy pathdocs-api.yml
File metadata and controls
139 lines (117 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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