From f0990debeee951daa5dd3925093a9b1933be1037 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 28 Aug 2024 09:39:18 -0300 Subject: [PATCH] feat: try to rename and escape : characters in filenames --- .github/workflows/build-docs.yml | 5 +++++ automation/build-docs/rename-and-update.sh | 25 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 automation/build-docs/rename-and-update.sh diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index a5b0a62..b533595 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -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 diff --git a/automation/build-docs/rename-and-update.sh b/automation/build-docs/rename-and-update.sh new file mode 100755 index 0000000..28b056d --- /dev/null +++ b/automation/build-docs/rename-and-update.sh @@ -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