feat: implement heroku's postdeploy deployment task

This occurs during the postdeploy on the first deploy of an app, mimicking heroku. It currently happens _after_ the `postdeploy` and `release` deploy tasks.
This commit is contained in:
Jose Diaz-Gonzalez
2021-02-21 21:00:14 -05:00
parent 4d13e0c2f6
commit f98e7702fb
6 changed files with 70 additions and 20 deletions

View File

@@ -18,7 +18,7 @@ teardown() {
}
@test "(app-json) app.json scripts" {
run deploy_app nodejs-express
run deploy_app python
echo "output: $output"
echo "status: $status"
assert_success
@@ -48,6 +48,16 @@ teardown() {
assert_success
}
@test "(app-json) app.json scripts postdeploy" {
run deploy_app python dokku@dokku.me:$TEST_APP add_postdeploy_command
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "touch /app/release.test" 2
assert_output_contains "python3 release.py" 2
}
@test "(app-json) app.json scripts missing" {
run deploy_app nodejs-express-noappjson
echo "output: $output"

View File

@@ -514,6 +514,17 @@ add_release_command() {
echo "release: touch /app/release.test" >>"$APP_REPO_DIR/Procfile"
}
add_postdeploy_command() {
local APP="$1"
local APP_REPO_DIR="$2"
[[ -z "$APP" ]] && local APP="$TEST_APP"
touch "$APP_REPO_DIR/app.json"
contents=$(jq '.scripts.postdeploy = "touch /app/heroku-postdeploy.test"' "$APP_REPO_DIR/app.json")
echo "${contents}" > "$APP_REPO_DIR/app.json"
}
add_requirements_txt() {
local APP="$1"
local APP_REPO_DIR="$2"