Skip to content

Instantly share code, notes, and snippets.

@Mte90 Mte90/pre-push.sh
Last active Jan 20, 2020

Embed
What would you like to do?
pre-push

I use this git hook to upload on a folder on our Dev VPS the status of the branch of a specific plugin, so we have an history.
It execute QualityAnalyzer, PHPMetrics and Codeception to generate the relative reports.

#!/bin/sh
# If the branch is not master, execute phpmetrics and upoload everything on the VPS
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $current_branch != "master" ]; then
sshpass -p your-password ssh user@domain.tld mkdir -p /var/www/your-path/status/master/
sshpass -p your-password rsync --progress -avzP /home/your-user/.cache/QualityAnalyzer/assets -e ssh user@domain.tld:/var/www/your-metrics/status/$current_branch/ > /dev/null
sshpass -p your-password rsync --progress -avzP /home/your-user/.cache/QualityAnalyzer/index.html -e ssh user@domain.tld:/var/www/your-metrics/status/$current_branch/ > /dev/null
/home/your-user/.cache/QualityAnalyzer/bin/analyze analyze /var/www/VVV/www/site/public_html/wp-content/plugins/your-plugin/ --exclude=vendor,cmb2,freemius,generated,WP_*,i18n*,*Core,Widgets-*,Wp-Dismi*,Requirements,CronPlus,WP_Query* --exclude_analyzers=cpd,pdepend,checkstyle
sshpass -p your-password rsync --exclude={.git*} --progress -avzP /home/your-user/.cache/QualityAnalyzer/data -e ssh user@domain.tld:/var/www/your-metrics//status/$current_branch/ > /dev/null
codecept run wpunit --coverage --coverage-html > /dev/null
sshpass -p your-password rsync --exclude={.git*} --progress -avzP /var/www/VVV/www/glossary/public_html/wp-content/plugins/your-plugin/tests/_output/coverage/ -e ssh user@domain.tld:/var/www/your-metrics/coverage > /dev/null
phpmetrics --report-html="/tmp/your-report" /var/www/VVV/www/your-project/public_html/wp-content/plugins/your-plugin/ --config=phpmetrics.ini > /dev/null
sshpass -p your-password rsync --exclude={.sass-cache*,*.map,node_modules,.php_cs,.git*,*.lock,*.yml,*lock.json} --progress -avz /tmp/your-report -e ssh user@domain.tld:/var/www/your-metrics/$current_branch/ > /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.