Skip to content

Commit

Permalink
Update CI to work with multi-views
Browse files Browse the repository at this point in the history
  • Loading branch information
pserwylo committed Jun 15, 2017
1 parent 32fcd1c commit 34ee22f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ f-droid.org:
- 'echo "baseurl: \"\"" >> userconfig.yml'
- echo "Additional Jekyll config used for CI:" && cat userconfig.yml
- bundle exec jekyll build -d $OUT_DIR --config _config.yml,userconfig.yml --verbose --trace
- ./tools/prepare-multi-lang.sh $OUT_DIR
- cp -r $OUT_DIR $DEPLOY_DIR/

build:
Expand All @@ -67,6 +68,7 @@ build:
- 'echo baseurl: /$CI_PROJECT_NAME >> userconfig.yml'
- echo "Additional Jekyll config used for CI:" && cat userconfig.yml
- bundle exec jekyll build -d $OUT_DIR/$CI_PROJECT_NAME --config _config.yml,userconfig.yml --verbose --trace
- ./tools/prepare-multi-lang.sh $OUT_DIR/$CI_PROJECT_NAME --no-multi-views


# This deploys feature branches to https://surge.sh, a free static site hosting service.
Expand All @@ -93,6 +95,7 @@ preview:
- 'echo fdroid-repo: https://guardianproject.info/fdroid/repo >> userconfig.yml'
- echo "Additional Jekyll config used for CI:" && cat userconfig.yml
- bundle exec jekyll build -d $OUT_DIR/$CI_PROJECT_NAME --config _config.yml,userconfig.yml --verbose --trace
- ./tools/prepare-multi-lang.sh $OUT_DIR/$CI_PROJECT_NAME --no-multi-views
- apt-get install -y npm
- npm install -g surge
- update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
Expand Down Expand Up @@ -144,3 +147,4 @@ pages:

- echo "Additional Jekyll config used for CI:" && cat userconfig.yml
- bundle exec jekyll build -d public --config _config.yml,userconfig.yml
- ./tools/prepare-multi-lang.sh public/$CI_PROJECT_NAME --no-multi-views
22 changes: 19 additions & 3 deletions tools/prepare-multi-lang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,25 @@ function relative_symlink {
ln -s ${SRC_RELATIVE_TO_DEST} ${DEST}
}


LANGS="fr"
cd _site

if [[ $# == 0 || ! -d $1/en ]]; then
echo "First argument must be the directory of the Jekyll website."
echo "This should take into account the baseurl as well. If the site"
echo "is output to 'build/' and the baseurl is 'fdroid-website/' then"
echo "the first argument should be 'build/fdroid-website/'"
exit 1
fi

cd $1

# For deploying to GitLab or surge.sh, we still want it to work, which requires leaving original English *.html files
# in the webroot rather than just MultiView compatible *.html.LANG files.
if [[ $# == 2 && $2 == "--no-multi-views" ]]; then
MULTI_VIEWS=false
else
MULTI_VIEWS=true
fi

find en/ -type f -print0 | while IFS= read -r -d '' FILE_PATH
do
Expand All @@ -78,7 +94,7 @@ do

mkdir -p ${DIR}

if [[ ${FILE} =~ ^(\.htaccess|.*\.css|.*\.js)$ ]]; then
if [[ ${MULTI_VIEWS} = false || ${FILE} =~ ^(\.htaccess|.*\.css|.*\.js)$ ]]; then
echo "Not generating i18n version of ${DIR}/${FILE}"
cp ${FILE_PATH} ${DIR}/${FILE}
continue;
Expand Down

0 comments on commit 34ee22f

Please sign in to comment.