Skip to content

Commit 36d2f39

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 36d2f39

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

.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/screenshots-upload/*.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: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ jobs:
4949
sudo gem install dupervisor -v 1.0.5 # To convert ini to yaml files
5050
sudo npm install -g asar # to get pacakges.json from resources/app.asar for electron-builder applications
5151
# npm install -g @alexlafroscia/yaml-merge # to merge yaml files
52+
- name: Mark screenshot start (PR only)
53+
if: github.event_name == 'pull_request'
54+
run: |
55+
touch .screenshots_start
5256
- name: Main test
5357
# shell: bash
5458
run: |
@@ -86,13 +90,26 @@ jobs:
8690
# xpra stop :99
8791
killall Xvfb
8892
# 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
93+
- name: Prepare screenshots for upload
94+
if: github.event_name == 'pull_request'
95+
shell: bash
96+
run: |
97+
mkdir -p screenshots-upload
98+
# only files modified during this run
99+
while IFS= read -r screenshot; do
100+
[ -f "$screenshot" ] || continue
101+
appname=$(basename "$(dirname "$screenshot")")
102+
# Sanitize filename: allow letters, digits, dot, underscore, hyphen
103+
safe_name=$(echo "$appname" | tr '[:upper:]' '[:lower:]' | tr -cd 'a-z0-9._-')
104+
cp "$screenshot" "screenshots-upload/${safe_name}.png"
105+
done < <(find database -type f -path '*/screenshot.png' -newer .screenshots_start -print)
106+
ls -la screenshots-upload/ || true
89107
- name: Upload screenshot artifact
90108
if: github.event_name == 'pull_request'
91109
uses: actions/upload-artifact@v4
92110
with:
93111
name: pr-screenshots
94-
path: |
95-
database/*/screenshot.png
112+
path: screenshots-upload/*.png
96113
if-no-files-found: ignore
97114
retention-days: 7
98115
- name: Check log

0 commit comments

Comments
 (0)