4949 SHORT_SHA=$(git rev-parse --short "$GITHUB_SHA")
5050 OUTDIR="site"
5151 mkdir -p "$OUTDIR"
52+ # Bring over existing reports so we can publish with keep_files=false safely
53+ if [ -d ghp/reports ]; then
54+ mkdir -p "$OUTDIR/reports"
55+ cp -R ghp/reports/* "$OUTDIR/reports/" || true
56+ fi
5257 # Decide sub path
5358 if [ -n "$PR_NUMBER" ]; then
5459 SUBPATH="reports/pr-${PR_NUMBER}/sha-${SHORT_SHA}"
@@ -66,18 +71,17 @@ jobs:
6671 if [ -f codestate_pr_report.json ]; then
6772 cp codestate_pr_report.json "$OUTDIR/$SUBPATH/codestate_pr_report.json"
6873 fi
69- # Build history list from existing gh-pages (if available )
74+ # Build history list from existing content in OUTDIR (copied + current )
7075 HISTORY_FILE_MD="$OUTDIR/history.md"
7176 echo "# CodeState Report History" > "$HISTORY_FILE_MD"
7277 echo >> "$HISTORY_FILE_MD"
7378 echo "Browse all published reports. Newest first." >> "$HISTORY_FILE_MD"
7479 echo >> "$HISTORY_FILE_MD"
7580 # Collect existing entries
76- if [ -d ghp/reports ]; then
77- # shellcheck disable=SC2012
78- EXISTING_INDEXES=$(find ghp/reports -type f -name index.html | sort -r)
81+ if [ -d "$OUTDIR/reports" ]; then
82+ EXISTING_INDEXES=$(find "$OUTDIR/reports" -type f -name index.html | sort -r)
7983 while IFS= read -r path; do
80- rel=${path#ghp /}
84+ rel=${path#${OUTDIR} /}
8185 # rel like reports/pr-123/sha-abc/index.html
8286 dir=$(dirname "$rel")
8387 base=$(basename "$dir")
@@ -113,7 +117,7 @@ jobs:
113117 publish_branch : gh-pages
114118 publish_dir : ./site
115119 enable_jekyll : true
116- keep_files : true
120+ keep_files : false
117121
118122 - name : Upload HTML artifact
119123 uses : actions/upload-artifact@v4
0 commit comments