1
1
name : Docs CI
2
2
3
+ # This workflow runs linting and formatting checks on documentation files.
4
+ # It leverages the shared docs-analysis composite action for detecting changes
5
+ # and integrates with other documentation workflows through shared outputs.
6
+ # Security features ensure safe handling of files and commands.
7
+
3
8
on :
4
9
push :
5
10
branches :
8
13
- " docs/**"
9
14
- " **.md"
10
15
- " .github/workflows/docs-ci.yaml"
16
+ - " .github/actions/docs-analysis/**"
11
17
12
18
pull_request :
13
19
paths :
14
20
- " docs/**"
15
21
- " **.md"
16
22
- " .github/workflows/docs-ci.yaml"
23
+ - " .github/actions/docs-analysis/**"
17
24
18
25
permissions :
19
26
contents : read
20
27
21
28
jobs :
22
29
docs :
23
30
runs-on : ubuntu-latest
31
+ outputs :
32
+ docs_changed : ${{ steps.docs-analysis.outputs.docs-changed }}
33
+ docs_files_count : ${{ steps.docs-analysis.outputs.docs-files-count }}
34
+ words_added : ${{ steps.docs-analysis.outputs.words-added }}
35
+ words_removed : ${{ steps.docs-analysis.outputs.words-removed }}
36
+ images_changed : ${{ steps.docs-analysis.outputs.images-total }}
37
+ significant_change : ${{ steps.docs-analysis.outputs.significant-change }}
24
38
steps :
39
+ - name : Harden Runner
40
+ uses : step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
41
+ with :
42
+ egress-policy : audit
43
+
25
44
- name : Checkout
26
45
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
46
+ with :
47
+ fetch-depth : 50 # Increased for better detection of doc changes
27
48
28
49
- name : Setup Node
29
50
uses : ./.github/actions/setup-node
@@ -35,14 +56,113 @@ jobs:
35
56
docs/**
36
57
**.md
37
58
separator : " ,"
59
+ fetch_depth : 50
60
+ since_last_remote_commit : ${{ github.event_name == 'push' }}
61
+
62
+ # Use our composite action to analyze documentation changes
63
+ - name : Analyze documentation changes
64
+ id : docs-analysis
65
+ uses : ./.github/actions/docs-analysis
66
+ with :
67
+ docs-path : " docs/"
68
+ changed-files : ${{ steps.changed-files.outputs.all_changed_files }}
69
+ files-pattern : " docs/**|**.md"
70
+ debug-mode : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug == 'true' || 'false' }}
71
+ # Enable throttling for large repositories
72
+ throttle-large-repos : ' true'
73
+ # Default performance optimization values
74
+ max-scan-files : ' 100'
75
+ max-files-to-analyze : ' 20'
38
76
39
77
- name : lint
40
- if : steps.changed-files .outputs.any_changed == 'true'
78
+ if : steps.docs-analysis .outputs.docs-changed == 'true'
41
79
run : |
42
80
pnpm exec markdownlint-cli2 ${{ steps.changed-files.outputs.all_changed_files }}
43
81
44
82
- name : fmt
45
- if : steps.changed-files .outputs.any_changed == 'true'
83
+ if : steps.docs-analysis .outputs.docs-changed == 'true'
46
84
run : |
47
85
# markdown-table-formatter requires a space separated list of files
48
86
echo ${{ steps.changed-files.outputs.all_changed_files }} | tr ',' '\n' | pnpm exec markdown-table-formatter --check
87
+
88
+ # Display metrics about documentation changes (only on PRs)
89
+ - name : Documentation metrics summary
90
+ if : github.event_name == 'pull_request' && steps.docs-analysis.outputs.docs-changed == 'true'
91
+ run : |
92
+ echo "## Documentation Changes Summary" >> $GITHUB_STEP_SUMMARY
93
+ echo "" >> $GITHUB_STEP_SUMMARY
94
+ echo "| Metric | Value |" >> $GITHUB_STEP_SUMMARY
95
+ echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
96
+ echo "| Files changed | ${{ steps.docs-analysis.outputs.docs-files-count }} |" >> $GITHUB_STEP_SUMMARY
97
+ echo "| Words added | ${{ steps.docs-analysis.outputs.words-added }} |" >> $GITHUB_STEP_SUMMARY
98
+ echo "| Words removed | ${{ steps.docs-analysis.outputs.words-removed }} |" >> $GITHUB_STEP_SUMMARY
99
+ echo "| Processing time | ${{ steps.docs-analysis.outputs.execution-time }}s |" >> $GITHUB_STEP_SUMMARY
100
+
101
+ if [[ "${{ steps.docs-analysis.outputs.images-total }}" != "0" ]]; then
102
+ echo "| Images changed | ${{ steps.docs-analysis.outputs.images-total }} |" >> $GITHUB_STEP_SUMMARY
103
+
104
+ # Add more detailed image metrics if available
105
+ if [[ "${{ steps.docs-analysis.outputs.images-added }}" != "0" || "${{ steps.docs-analysis.outputs.images-modified }}" != "0" || "${{ steps.docs-analysis.outputs.images-deleted }}" != "0" ]]; then
106
+ IMAGES_DETAIL=""
107
+ if [[ "${{ steps.docs-analysis.outputs.images-added }}" != "0" ]]; then
108
+ IMAGES_DETAIL="${{ steps.docs-analysis.outputs.images-added }} added"
109
+ fi
110
+ if [[ "${{ steps.docs-analysis.outputs.images-modified }}" != "0" ]]; then
111
+ if [[ -n "$IMAGES_DETAIL" ]]; then
112
+ IMAGES_DETAIL="$IMAGES_DETAIL, ${{ steps.docs-analysis.outputs.images-modified }} modified"
113
+ else
114
+ IMAGES_DETAIL="${{ steps.docs-analysis.outputs.images-modified }} modified"
115
+ fi
116
+ fi
117
+ if [[ "${{ steps.docs-analysis.outputs.images-deleted }}" != "0" ]]; then
118
+ if [[ -n "$IMAGES_DETAIL" ]]; then
119
+ IMAGES_DETAIL="$IMAGES_DETAIL, ${{ steps.docs-analysis.outputs.images-deleted }} deleted"
120
+ else
121
+ IMAGES_DETAIL="${{ steps.docs-analysis.outputs.images-deleted }} deleted"
122
+ fi
123
+ fi
124
+ echo "| Images detail | $IMAGES_DETAIL |" >> $GITHUB_STEP_SUMMARY
125
+ fi
126
+ fi
127
+
128
+ if [[ "${{ steps.docs-analysis.outputs.manifest-changed }}" == "true" ]]; then
129
+ echo "| Structure changes | Yes (manifest.json modified) |" >> $GITHUB_STEP_SUMMARY
130
+ fi
131
+
132
+ if [[ "${{ steps.docs-analysis.outputs.format-only }}" == "true" ]]; then
133
+ echo "| Format only | Yes (no content changes) |" >> $GITHUB_STEP_SUMMARY
134
+ fi
135
+
136
+ # Add most changed file info if available
137
+ if [[ "${{ steps.docs-analysis.outputs.most-changed-file }}" != "" ]]; then
138
+ echo "| Most changed file | \`${{ steps.docs-analysis.outputs.most-changed-file }}\` |" >> $GITHUB_STEP_SUMMARY
139
+ fi
140
+
141
+ # Create job summary for GitHub Actions UI
142
+ - name : Job status summary
143
+ if : always()
144
+ run : |
145
+ STATUS="${{ job.status }}"
146
+
147
+ if [[ "$STATUS" == "success" ]]; then
148
+ echo "## ✅ Documentation checks passed" >> $GITHUB_STEP_SUMMARY
149
+ else
150
+ echo "## ❌ Documentation checks failed" >> $GITHUB_STEP_SUMMARY
151
+ fi
152
+
153
+ echo "" >> $GITHUB_STEP_SUMMARY
154
+ echo "Ran with:" >> $GITHUB_STEP_SUMMARY
155
+ echo "- Docs Analysis version: $(cd .github/actions/docs-analysis && git rev-parse --short HEAD || echo 'unknown')" >> $GITHUB_STEP_SUMMARY
156
+ echo "- Event: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
157
+
158
+ # Output useful links for debugging
159
+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
160
+ echo "- [View PR](https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }})" >> $GITHUB_STEP_SUMMARY
161
+ fi
162
+
163
+ # Output performance metrics
164
+ if [[ -f ".github/temp/docs-analysis-metrics.json" ]]; then
165
+ echo "" >> $GITHUB_STEP_SUMMARY
166
+ echo "### Performance Metrics" >> $GITHUB_STEP_SUMMARY
167
+ echo "$(cat .github/temp/docs-analysis-metrics.json | grep -o '"execution_time": [0-9]*' | cut -d' ' -f2) seconds to analyze documentation" >> $GITHUB_STEP_SUMMARY
168
+ fi
0 commit comments