Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
fix(Travis): Fixes release artifacts generated by Travis. (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Gratacos authored and e0ipso committed Aug 20, 2017
1 parent 7886be8 commit 9e3264c
Showing 1 changed file with 62 additions and 38 deletions.
100 changes: 62 additions & 38 deletions scripts/ci/travis/before_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,51 @@ validate_env_var() {
done
}

# ContentaCMS Files To Delete List Function
# This function receives no argument
# List of least minimum files needed for Contenta CMS to work
contentacms_files_to_delete_list() {
list=(
'.circleci'
'CODE_OF_CONDUCT.md'
'.editorconfig'
'.git'
'.github'
'.gitignore'
'installer.sh'
'tests'
'.travis.yml'
'.mkdocks.yml'
'phpunit.xml'
)

echo ${list[*]}
# Remove files on folder
# This function removes a list of files or folder that may exist on a giving path
# This function receives two argument:
# $1 -> Path of the folder that contains the files and/or folder to be deleted
# $2 -> List of folder and/or file names to be deleted.
# $3 -> Name of the function that is currently calling rm_files_on_folder function
rm_files_on_folder() {
if [ -z $1 ] ; then
echo "Please pass a folder path to rm_files_on_folder that contains files to be deleted as \$1" 1>&2
exit 1
elif [ -z $2 ] ; then
echo "Please pass a list of files or folder to rm_files_on_folder that are going to be removed as \$2" 1>&2
exit 1
elif [ -z $3 ]; then
echo "Please pass the name of the function that is calling rm_files_on_folder as \$3" 1>&2
exit 1
fi

path=$1

list_of_files_in_folder=$(ls -a $1)

list_to_delete=$2

for VAR in $list_of_files_in_folder
do
if [ "$VAR" == "." ] || [ "$VAR" == ".." ]; then
continue
elif [[ " ${list_to_delete[@]} " =~ " $VAR " ]]; then
if [ -d "$path/$VAR" ] || [ -f "$path/$VAR" ]; then
echo "Removing: $path/$VAR"
sudo rm -rf $path/$VAR
else
echo "\e[33mWARNING:\e[0m '$path/$VAR' does not exist, please check $3 function and fix the value in the list"
fi
fi
done
}

# Zip Folder Function
# This function receives two argument:
# This function receives three argument:
# $1 -> Parent path of the folder that is going to be compressed
# $2 -> Folder Name that is going to be compressed
# $3 -> Zip Folder Name
zip_folder(){

# Validate that 2 arguments were passed
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then
echo "Please pass a parent folder path, the folder name and zip name to the zip_folder function" 1>&2
Expand All @@ -59,46 +76,53 @@ zip_folder(){
# This function receives one argument:
# $1 -> The Drupal Base Path
rm_site(){

if [ -z $1 ] ; then
echo "Please pass a Drupal Base Path to the rm_site function" 1>&2
exit 1
fi

default_dir=$1/sites/default

sudo rm -rf $default_dir/settings.php \
$default_dir/services.yml \
$default_dir/files
list=(
"settings.php"
"services.yml"
"files"
)

rm_files_on_folder $default_dir "${list[*]}" "rm_site"

echo "Successfully cleaned up '${list[*]}' in '$default_dir'."
}

# ContentaCMS Profile Cleanup Function
# Cleanup every unnecessary file/folder inside the ContentaCMS Profile folder
# This function receives one argument:
# $1 -> The Drupal Base Path
contentacms_profile_cleanup(){

if [ -z $1 ] ; then
echo "Please pass a Drupal Base Path to the contenta_profile_cleanup function" 1>&2
exit 1
fi

list=$(contentacms_files_to_delete_list)
list=(
'.circleci'
'CODE_OF_CONDUCT.md'
'.editorconfig'
'.git'
'.github'
'.gitignore'
'installer.sh'
'tests'
'.travis.yml'
'mkdocs.yml'
'phpunit.xml'
)

profile_contenta=$1/profiles/contrib/contenta_jsonapi

list_of_files=$(ls -a $profile_contenta)

for VAR in $list_of_files
do
if [ "$VAR" == "." ] || [ "$VAR" == ".." ]; then
continue
elif [[ " ${list[@]} " =~ " $VAR " ]]; then
echo "Removing: $profile_contenta/$VAR"
sudo rm -rf $profile_contenta/$VAR
fi
rm_files_on_folder $profile_contenta "${list[*]}" "contentacms_profile_cleanup"

done
echo "Successfully cleaned up '${list[*]}' in '$profile_contenta'."
}

$@

0 comments on commit 9e3264c

Please sign in to comment.