Skip to content

Instantly share code, notes, and snippets.

@literalplus
Created January 6, 2016 00:57
Show Gist options
  • Save literalplus/916de6497aeed1d3a922 to your computer and use it in GitHub Desktop.
Save literalplus/916de6497aeed1d3a922 to your computer and use it in GitHub Desktop.
Random PHP "build" script
#!/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