Created
January 6, 2016 00:57
-
-
Save literalplus/916de6497aeed1d3a922 to your computer and use it in GitHub Desktop.
Random PHP "build" script
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
#!/bin/sh | |
if [ "$GIT_COMMIT" == "" ]; then | |
GIT_COMMIT="unknown" | |
fi | |
if [ ! -f data/config.php ]; then | |
cp data/config.php.example data/config.php | |
echo "Copied default config to data/config.php!" | |
fi | |
sed -r -i.prev -e "\ | |
s/(define\('GIT_COMMIT', ').+?'\);/\1$GIT_COMMIT'\);/g;\ | |
s/(define\('LAST_UPDATE', ').+?'\);/\1$(date)'\);/g" data/config.php | |
# Check PHP files for syntax errors | |
error=false | |
for file in `find . -type f -name "*.php"`; do | |
RESULTS=`php -l $file` | |
if [ "$RESULTS" != "No syntax errors detected in $file" ]; then | |
echo $RESULTS | |
error=true | |
fi | |
done | |
if [ "$error" = true ]; then | |
echo "BUILD FAILURE: PHP Syntax errors!" | |
exit 1 | |
else | |
echo "BUILD SUCCESS" | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment