Skip to content

Commit 85bb052

Browse files
authored
Heroku release command bash wrapper (github#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
1 parent a182ffb commit 85bb052

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

Procfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
web: NODE_ENV=production node server.js
22

3-
release: NODE_ENV=production node script/purge-redis-pages.js
3+
release: NODE_ENV=production script/release-heroku

script/release-heroku

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
# [start-readme]
4+
#
5+
# Light Bash wrapper for the Heroku release command, which sometimes fails
6+
# unexpectedly in staging environments when a Node installation is missing
7+
#
8+
# [end-readme]
9+
10+
# Check for node but don't fail immediately if it's not present
11+
./script/check-for-node
12+
EXIT_STATUS=$?
13+
14+
# If node is missing...
15+
if [[ "$EXIT_STATUS" -ne "0" ]]; then
16+
# Fail hard if this is our Heroku production app or if Redis is configured
17+
if [[ "$HEROKU_PRODUCTION_APP" == "true" || -n "$REDIS_URL" ]]; then
18+
echo "Error: cannot execute the release script without Node.js, which is fatal."
19+
echo "Exiting..."
20+
exit $EXIT_STATUS
21+
# Otherwise succeed with only a warning
22+
else
23+
echo "Warning: although Node.js is missing, it is non-critical."
24+
echo "Exiting..."
25+
exit 0
26+
fi
27+
fi
28+
29+
# Execute the release script and exit with its status
30+
node script/purge-redis-pages.js
31+
exit $?

0 commit comments

Comments
 (0)