-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_push
24 lines (20 loc) · 1.16 KB
/
docker_push
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
set -e
# HEROKU_AUTH_TOKEN is a Travis CI protected variable, generated using
# https://dashboard.heroku.com/account/applications then set in Travis
# cf. https://docs.travis-ci.com/user/environment-variables/#defining-variables-in-repository-settings
# and https://devcenter.heroku.com/articles/container-registry-and-runtime#logging-in-to-the-registry
# and https://docs.travis-ci.com/user/docker/#private-registry-login
echo "$HEROKU_AUTH_TOKEN" | docker login -u _ --password-stdin registry.heroku.com
docker tag "$DOCKER_IMAGE" registry.heroku.com/"$PROJECT_NAME"
docker push registry.heroku.com/"$PROJECT_NAME":latest
docker logout
# cf. https://devcenter.heroku.com/articles/container-registry-and-runtime#api
# and https://toedter.com/2018/06/02/heroku-docker-deployment-update/
imageId=$(docker inspect $DOCKER_IMAGE --format="{{.Id}}")
payload="{\"updates\": [{\"type\": \"web\", \"docker_image\": \"$imageId\"}]}"
curl -n -X PATCH https://api.heroku.com/apps/"$PROJECT_NAME"/formation \
-d "$payload" \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.heroku+json; version=3.docker-releases" \
-H "Authorization: Bearer $HEROKU_AUTH_TOKEN"