Skip to content

Commit 29420f9

Browse files
committed
sanitize filenames for artifact upload
- Add step to sanitize screenshot filenames before upload - Remove invalid characters (: * ? < > |) from app names - Fixes error with apps like 'fre:ac' containing colons - Update publish workflow to handle flat file structure
1 parent e8788ea commit 29420f9

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

.github/workflows/publish-pr-screenshot.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@ jobs:
4848
SHORT="${HEAD_SHA::8}"
4949
COUNT=0
5050
FALLBACK="run-${{ github.event.workflow_run.id }}"
51-
for f in out/database/*/screenshot.png; do
51+
for f in out/*.png; do
5252
[ -f "$f" ] || continue
5353
base="$(basename "$f")"
54-
ext="${base##*.}"
55-
appname="$(basename "$(dirname "$f")")"
54+
appname="${base%.png}" # Remove .png extension to get app name
5655
# Produce deterministic upload name with app name
5756
PN="${PR_NUMBER:-$FALLBACK}"
58-
name="pr-${PN}-${SHORT}-${appname}.${ext}"
57+
name="pr-${PN}-${SHORT}-${appname}.png"
5958
cp "$f" "upload/${name}"
6059
echo "${name}" >> upload/list.txt
6160
COUNT=$((COUNT+1))

.github/workflows/test.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,26 @@ jobs:
8686
# xpra stop :99
8787
killall Xvfb
8888
# bundle exec jekyll build # https://help.github.com/en/articles/viewing-jekyll-build-error-messages#configuring-a-third-party-service-to-display-jekyll-build-error-messages
89+
- name: Prepare screenshots for upload
90+
if: github.event_name == 'pull_request'
91+
shell: bash
92+
run: |
93+
mkdir -p screenshots-upload
94+
for screenshot in database/*/screenshot.png; do
95+
if [ -f "$screenshot" ]; then
96+
appname=$(basename "$(dirname "$screenshot")")
97+
# Sanitize filename: remove invalid characters for artifacts
98+
safe_name=$(echo "$appname" | tr -d '":*?<>|' | tr ' ' '_')
99+
cp "$screenshot" "screenshots-upload/${safe_name}.png"
100+
fi
101+
done
102+
ls -la screenshots-upload/ || true
89103
- name: Upload screenshot artifact
90104
if: github.event_name == 'pull_request'
91105
uses: actions/upload-artifact@v4
92106
with:
93107
name: pr-screenshots
94-
path: |
95-
database/*/screenshot.png
108+
path: screenshots-upload/*.png
96109
if-no-files-found: ignore
97110
retention-days: 7
98111
- name: Check log

0 commit comments

Comments
 (0)