1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Heroku release command bash wrapper (#18743)

* Add tiny Bash wrapper to check for Node before attempting to execute Heroku release script

* Use the wrapper script for the Heroku release command

* Be explicit about exiting with Node's exit code

* If Node is missing, exit using that script's exit code
This commit is contained in:
James M. Greene
2021-04-13 16:12:20 -05:00
committed by GitHub
parent a182ffbd98
commit 85bb052b4f
2 changed files with 32 additions and 1 deletions

View File

@@ -1,3 +1,3 @@
web: NODE_ENV=production node server.js web: NODE_ENV=production node server.js
release: NODE_ENV=production node script/purge-redis-pages.js release: NODE_ENV=production script/release-heroku

31
script/release-heroku Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# [start-readme]
#
# Light Bash wrapper for the Heroku release command, which sometimes fails
# unexpectedly in staging environments when a Node installation is missing
#
# [end-readme]
# Check for node but don't fail immediately if it's not present
./script/check-for-node
EXIT_STATUS=$?
# If node is missing...
if [[ "$EXIT_STATUS" -ne "0" ]]; then
# Fail hard if this is our Heroku production app or if Redis is configured
if [[ "$HEROKU_PRODUCTION_APP" == "true" || -n "$REDIS_URL" ]]; then
echo "Error: cannot execute the release script without Node.js, which is fatal."
echo "Exiting..."
exit $EXIT_STATUS
# Otherwise succeed with only a warning
else
echo "Warning: although Node.js is missing, it is non-critical."
echo "Exiting..."
exit 0
fi
fi
# Execute the release script and exit with its status
node script/purge-redis-pages.js
exit $?