This repository has been archived by the owner on Sep 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(version): add script to update version list
Signed-off-by: Naylin Medina <[email protected]>
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "[email protected]" | ||
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 |