-
Notifications
You must be signed in to change notification settings - Fork 1
199 lines (170 loc) · 6.41 KB
/
Copy pathbuild-html.yml
File metadata and controls
199 lines (170 loc) · 6.41 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Build HTML & Deploy
on:
workflow_dispatch:
inputs:
title:
description: 'Documentation title'
required: false
type: string
default: 'Lich 5 Documentation'
clean:
description: 'Clean output directory before building'
required: false
type: boolean
default: true
deploy:
description: 'Deploy to GitHub Pages after build'
required: false
type: boolean
default: true
# Permissions for both committing and deploying to Pages
permissions:
contents: write
pages: write
id-token: write
# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build-and-deploy:
runs-on: ubuntu-latest
name: Build HTML & Deploy to Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: false
- name: Install YARD
run: gem install yard
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Check for documented files
id: check-files
run: |
if [ -d "documented" ]; then
file_count=$(find documented -name "*.rb" | wc -l)
echo "file_count=$file_count" >> $GITHUB_OUTPUT
echo "Found $file_count documented Ruby files"
else
echo "file_count=0" >> $GITHUB_OUTPUT
echo "❌ documented/ directory not found"
fi
- name: Build HTML documentation
if: steps.check-files.outputs.file_count > 0
run: |
args=""
if [ "${{ inputs.clean }}" == "true" ]; then
args="$args --clean"
fi
python build_html.py \
--input ./documented \
--output ./docs \
--title "${{ inputs.title }}" \
--verify $args
- name: Verify docs output
if: steps.check-files.outputs.file_count > 0
id: verify-docs
run: |
if [ -d "docs" ] && [ -f "docs/index.html" ]; then
html_count=$(find docs -name "*.html" | wc -l)
echo "html_count=$html_count" >> $GITHUB_OUTPUT
echo "has_docs=true" >> $GITHUB_OUTPUT
echo "✅ Generated $html_count HTML files"
else
echo "has_docs=false" >> $GITHUB_OUTPUT
echo "❌ docs/index.html not found"
fi
- name: Check for changes
if: steps.verify-docs.outputs.has_docs == 'true'
id: check-changes
run: |
git add docs/
if git diff --staged --quiet; then
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "No changes to commit"
else
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "Changes detected in docs/"
fi
- name: Commit HTML documentation
if: steps.check-changes.outputs.has_changes == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "$(cat <<'EOF'
Build HTML documentation
Generated ${{ steps.verify-docs.outputs.html_count }} HTML files from documented Ruby files.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
git push
echo "✅ HTML documentation committed"
# Deploy to GitHub Pages
- name: Setup Pages
if: inputs.deploy && steps.verify-docs.outputs.has_docs == 'true'
uses: actions/configure-pages@v4
- name: Upload Pages artifact
if: inputs.deploy && steps.verify-docs.outputs.has_docs == 'true'
uses: actions/upload-pages-artifact@v3
with:
path: 'docs'
- name: Deploy to GitHub Pages
if: inputs.deploy && steps.verify-docs.outputs.has_docs == 'true'
id: deployment
uses: actions/deploy-pages@v4
- name: Upload build artifacts
if: always() && steps.verify-docs.outputs.has_docs == 'true'
uses: actions/upload-artifact@v4
with:
name: html-documentation
path: docs/
retention-days: 30
- name: Summary
if: always()
run: |
echo "### HTML Documentation Build" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Title:** ${{ inputs.title }}" >> $GITHUB_STEP_SUMMARY
echo "**Ruby files:** ${{ steps.check-files.outputs.file_count }}" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.verify-docs.outputs.has_docs }}" == "true" ]; then
echo "**HTML files:** ${{ steps.verify-docs.outputs.html_count }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.check-changes.outputs.has_changes }}" == "true" ]; then
echo "**Build:** ✅ Committed" >> $GITHUB_STEP_SUMMARY
else
echo "**Build:** ℹ️ No changes (already up to date)" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ inputs.deploy }}" == "true" ]; then
if [ -n "${{ steps.deployment.outputs.page_url }}" ]; then
echo "**Deploy:** ✅ Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📖 **URL:** ${{ steps.deployment.outputs.page_url }}" >> $GITHUB_STEP_SUMMARY
else
echo "**Deploy:** ⚠️ Skipped or failed" >> $GITHUB_STEP_SUMMARY
fi
else
echo "**Deploy:** ⏭️ Skipped (disabled)" >> $GITHUB_STEP_SUMMARY
fi
elif [ "${{ steps.check-files.outputs.file_count }}" == "0" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Status:** ⚠️ No documented files found" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Run **generate-docs** first to create documented Ruby files." >> $GITHUB_STEP_SUMMARY
else
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Status:** ❌ Build failed" >> $GITHUB_STEP_SUMMARY
fi