Skip to content

Commit

Permalink
Merge pull request #91 from DroidKaigi/takahirom/fix-name-restriction…
Browse files Browse the repository at this point in the history
…-of-file-for-comparison-ci/2024-07-05

Fix file name restriction for comparison CI
  • Loading branch information
takahirom authored Jul 5, 2024
2 parents 1177eb3 + 2e7f749 commit 04aa5dc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/screenshot-comparison-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
# Check for invalid file names and add only valid ones
exist_valid_files="false"
for file in "${files_to_add[@]}"; do
if [[ $file =~ ^[a-zA-Z0-9_./-]+$ ]]; then
if [[ $file =~ ^[a-zA-Z0-9_./\[\]\- ]+$ ]]; then
exist_valid_files="true"
break
fi
Expand All @@ -83,7 +83,7 @@ jobs:
# Check for invalid file names and add only valid ones
for file in $files_to_add; do
if [[ "$file" =~ ^[a-zA-Z0-9_./-]+$ ]]; then
if [[ "$file" =~ ^[a-zA-Z0-9_./\[\]\- ]+$ ]]; then
git add "$file"
fi
done
Expand All @@ -99,7 +99,7 @@ jobs:
shell: bash
run: |
# Find all the files ending with _compare.png in roborazzi folder
files=$(find . -type f -name "*_compare.png" | grep "roborazzi/" | grep -E "^[a-zA-Z0-9_./-]+$")
files=$(find . -type f -name "*_compare.png" | grep "roborazzi/" | grep -E "^[a-zA-Z0-9_./\[\]\- ]+$")
delimiter="$(openssl rand -hex 8)"
{
echo "reports<<${delimiter}"
Expand All @@ -115,6 +115,8 @@ jobs:
# Get the file name and insert newlines every 20 characters
fileName=$(basename "$file" | sed -r 's/(.{20})/\1<br>/g')
urlPart="${BRANCH_NAME//#/%23}/${file//#/%23}"
urlPart="${urlPart//[/%5B}"
urlPart="${urlPart//]/%5D}"
echo "| [$fileName](https://github.com/${{ github.repository }}/blob/$urlPart) | ![](https://github.com/${{ github.repository }}/blob/$urlPart?raw=true) |" >> "$GITHUB_OUTPUT"
done
echo "${delimiter}" >> "$GITHUB_OUTPUT"
Expand Down

0 comments on commit 04aa5dc

Please sign in to comment.