From 325d33c998618e46feccaef400328ac458a8eac2 Mon Sep 17 00:00:00 2001 From: Naylin Medina Date: Fri, 5 Oct 2018 17:37:49 -0400 Subject: [PATCH] ci(version): add script to update version list Signed-off-by: Naylin Medina --- _data/whitelist_version.yml | 0 ci/update_version_list.sh | 46 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 _data/whitelist_version.yml create mode 100644 ci/update_version_list.sh diff --git a/_data/whitelist_version.yml b/_data/whitelist_version.yml new file mode 100644 index 0000000..e69de29 diff --git a/ci/update_version_list.sh b/ci/update_version_list.sh new file mode 100644 index 0000000..83a9ae2 --- /dev/null +++ b/ci/update_version_list.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +COMMIT_MESSAGE=$(git log --pretty=oneline -n 1 $CIRCLE_SHA1) + +# only update list when documentation is updated +if [[ $COMMIT_MESSAGE == *"ci(docs): generate documentation with jazzy for version"* && -z "$CIRCLE_PULL_REQUEST" ]]; then + +# check if support folder exists +if [ -d "development/code-documentation/support" ]; then + +# remove list to create a new one and not duplicate folders +rm ./_data/whitelist_version.yml + +# create fresh list +touch ./_data/whitelist_version.yml + +# set path to directory where the versions folders are +FOLDER_PATH="development/code-documentation/support" + +# get folders in release directory +DIRS=`ls $FOLDER_PATH` + +# add version folders to list +for DIR in $DIRS +do +echo - ${DIR} >> ./_data/whitelist_version.yml +done +# if the list has changed commit and push changes + if [ -n "$(git status --porcelain _data/whitelist_version.yml)" ]; then + + echo "Updating version list" + + # configure git + git config --global user.email "apps@teclib.com" + git config --global user.name "Teclib' bot" + + # add new remote to push changes + git remote remove origin + git remote add origin https://$GITHUB_USER:$GITHUB_TOKEN@github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git + + git add _data/whitelist_version.yml && git commit -m "ci(list): update version list" + git push origin gh-pages + fi +fi + +fi \ No newline at end of file