ci(gitlabci): filter out docs src languages not declared in .i18n-filter file before build

This commit is contained in:
Yassine Doghri 2022-04-14 12:09:40 +00:00
parent 79c553cbad
commit b870ce55bc
3 changed files with 35 additions and 0 deletions

View File

@ -7,6 +7,8 @@ stages:
.documentation-setup:
before_script:
- cd docs
- chmod +x ./scripts/i18n-filter.sh
- ./scripts/i18n-filter.sh
- npm ci
cache:

29
docs/scripts/i18n-filter.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
# This script deletes language files not declared in the .i18n-filter file
set -e
# Exit if the directory isn't found
if [ ! -d $1 ]
then
echo "$1 directory does not exist."
exit
fi
cd $1
# Exit if the .i18n-filter isn't found
if [[ -f .i18n-filter ]]
then
# delete all languages not present in .i18n-filter
for i in *; do
if ! grep -qxFe "$i" .i18n-filter; then
echo "Deleting: $i"
rm -rf "$i"
fi
done
else
echo "$1/.i18n-filter file not found!"
exit
fi

4
docs/src/.i18n-filter Normal file
View File

@ -0,0 +1,4 @@
public
contributing
getting-started
index.md