Skip to content

Commit

Permalink
feat: try to rename and escape : characters in filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberb committed Aug 28, 2024
1 parent 58f16bd commit f0990de
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ jobs:
name: docs
path: ./automation/build-docs/docs-website

- name: Run rename and update script
run: |
cd ./automation/build-docs/
./rename-and-update.sh
deploy-docs:
runs-on: macos-latest
needs: build-docs
Expand Down
25 changes: 25 additions & 0 deletions automation/build-docs/rename-and-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Set locale to UTF-8 to avoid illegal byte sequence errors
export LC_CTYPE=C
export LANG=C

STATIC_FILES_FOLDER_PATH="./docs-website"

# Find all files with colons in their names, rename them, and update references
find $STATIC_FILES_FOLDER_PATH -depth -name '*:*' \
| while IFS= read -r file; do
# Generate the new name by replacing colons with underscores
new_name="$(dirname "$file")/$(basename "$file" | tr ':' '_')"

# Rename the file
mv "$file" "$new_name"

# Escape slashes and special characters for sed
escaped_file=$(printf '%s\n' "$(basename "$file")" | sed 's/[][\\/.^$*]/\\&/g')
escaped_new_name=$(printf '%s\n' "$(basename "$new_name")" | sed 's/[][\\/.^$*]/\\&/g')

# Update only the specific references to the renamed file within the documentation
grep -rl "$escaped_file" $STATIC_FILES_FOLDER_PATH \
| xargs sed -i '' "s/$escaped_file/$escaped_new_name/g"
done

0 comments on commit f0990de

Please sign in to comment.