@@ -51,50 +51,60 @@ jobs:
51
51
npm install --save-dev pa11y-ci
52
52
npx puppeteer browsers install chrome
53
53
54
- - name : Identify all HTML files in _build/html
54
+ - name : Identify HTML files with corresponding .md or .ipynb source
55
55
id : map_html_targets
56
56
shell : bash
57
57
run : |
58
- find _build/html -type f -name '*.html' | jq -R . | jq -s . > pa11y_targets.json
58
+ echo "[" > pa11y_targets.json
59
+ first=true
60
+
61
+ # Find all .md and .ipynb files (excluding hidden and irrelevant folders)
62
+ find . -type f \( -name "*.md" -o -name "*.ipynb" \) ! -path "./.*" ! -path "./_build/*" | while read -r source; do
63
+ # Strip leading ./ and extension
64
+ relative_path="${source#./}"
65
+ base_path="${relative_path%.*}"
66
+
67
+ # Match corresponding HTML file in _build/html
68
+ html_path="_build/html/${base_path}.html"
69
+ if [[ -f "$html_path" ]]; then
70
+ if [ "$first" = true ]; then
71
+ first=false
72
+ else
73
+ echo "," >> pa11y_targets.json
74
+ fi
75
+ echo "\"$html_path\"" >> pa11y_targets.json
76
+ fi
77
+ done
78
+
79
+ echo "]" >> pa11y_targets.json
80
+
59
81
echo "Generated pa11y_targets.json:"
60
82
cat pa11y_targets.json
61
83
62
84
63
- - name : Run Pa11y CI on changed pages only and save output
85
+ - name : Run Pa11y CI once on all targets and save output
64
86
id : run_pa11y
65
87
shell : bash
66
88
run : |
67
- num_files=$(jq length pa11y_targets.json)
68
89
touch pa11y_output.md
69
90
91
+ num_files=$(jq length pa11y_targets.json)
70
92
if [ "$num_files" -eq 0 ]; then
71
93
echo "No relevant HTML files to check. Skipping Pa11y." | tee pa11y_output.md
72
94
else
73
95
echo "### 🚦 Pa11y Accessibility Report" > pa11y_output.md
74
96
echo "" >> pa11y_output.md
75
97
76
- mapfile -t html_files < <(jq -r '.[]' pa11y_targets.json | sort -u)
77
- total_files=${#html_files[@]}
78
-
79
- for i in "${!html_files[@]}"; do
80
- file="${html_files[$i]}"
81
- current_index=$((i + 1))
82
- echo "🔎 Checking $current_index of $total_files: $file"
98
+ # Run pa11y-ci once on all files in pa11y_targets.json
99
+ result=$(npx pa11y-ci --reporter cli --config pa11yci.js 2>&1 || true)
100
+ echo "$result" >> pa11y_output.md
83
101
84
- echo "#### 📄 $file" >> pa11y_output.md
85
- echo '```' >> pa11y_output.md
86
-
87
- result=$(npx pa11y-ci --reporter cli --config pa11yci.js "file://$(pwd)/$file" 2>&1 || true)
88
- echo "$result" >> pa11y_output.md
89
- echo '```' >> pa11y_output.md
90
-
91
- base=$(basename "$file" .html)
92
- echo "_⚠️ Any errors likely originates from the source file (e.g., \`filename.md\`, \`filename.ipynb\`) used to generate the HTML._" >> pa11y_output.md
93
- echo "" >> pa11y_output.md
94
- done
102
+ echo "" >> pa11y_output.md
103
+ echo "_⚠️ Any errors likely originate from the source file (e.g., \`filename.md\`, \`filename.ipynb\`)._" >> pa11y_output.md
95
104
fi
96
105
97
106
107
+
98
108
- name : 🔍 Debug comment body
99
109
run : |
100
110
echo "------- BEGIN COMMENT BODY -------"
0 commit comments