Last active
June 8, 2017 23:24
-
-
Save xtfer/ab6c94b8405f12d241b0cbc36bbcdabc to your computer and use it in GitHub Desktop.
Platform.sh shortcuts
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
# Run a cron command only on a given branch | |
if [ "$PLATFORM_BRANCH" = master ]; then | |
bin/console whatever | |
fi | |
# And the short version | |
cmd: '[ "$PLATFORM_BRANCH" = "master" ] && bin/console whatever' | |
# Test that an environment works before merging | |
CODE=$(curl -s -w '%{http_code}' $(platform url -e dev --pipe | head -n 1) -o /dev/null) | |
[ "$CODE" = 200 ] && platform merge -e dev | |
# To be able to rebuild without new code changes you can issue the command | |
git commit --allow-empty -m'rebuild' && git push | |
# Write platform.sh environment variables to a file | |
php -r "echo json_decode(base64_decode(getenv('PLATFORM_VARIABLES')), true)['FILE_VALUE'];" > file_name.txt | |
# or | |
python -c 'import json,base64,os;print json.loads(base64.b64decode(os.getenv("PLATFORM_VARIABLES")))["FILE_VALUE"];' > file_name.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment