I'm trying to build Bitbucket pipeline (Dockerize) for Heroku CD of my .NET core web API project. My pipeline script:
image: atlassian/default-image:3
options:
docker: true
pipelines:
branches:
'develop':
- step:
name: Docker Build And Push
deployment: Develop
services:
- docker
caches:
- docker
script:
- echo "Docker Build"
- docker build -t $HEROKU_APP_NAME .
- echo "Heroku Registry Login"
- docker login --username=_ --password=$HEROKU_API_KEY registry.heroku.com
- echo "Heroku Image Tagging"
- docker tag $HEROKU_APP_NAME registry.heroku.com/$HEROKU_APP_NAME/web
- echo "Heroku Docker Push"
- docker push registry.heroku.com/$HEROKU_APP_NAME/web
- docker inspect registry.heroku.com/$HEROKU_APP_NAME/web --format='{{.Id}}' > HEROKU_DOCKER_IMAGE_ID
- echo "Heroku Publish Done"
- echo "??? How to execute 'heroku container:release web -a $HEROKU_APP_NAME'"
artifacts:
- HEROKU_DOCKER_IMAGE_ID
The pipeline script running fine with results:
- I can do docker image build
- Docker login into Heroku registry
- Push docker build into Heroku registry
- Get the last pushed image from Heroku registry for my application
The last step that necessary for Heroku to update the running application with latest uploaded docker image. If using PowerShell, the command is:
heroku container:release web -a <<app-name>>
But since this process run within Bitbucket pipeline, there's no Heroku CLI to execute (I've tried adding the Heroku npm, but the packages are deprecated).
I've also tried using shell script (.sh) for Platform API Container Registry & Runtime (Docker Deploys):
#!/usr/bin/env bash
curl -n -X PATCH https://api.heroku.com/apps/$HEROKU_APP_NAME/formation \
-d '{
"updates": [
{
"type": "web",
"docker_image": "'"$HEROKU_DOCKER_IMAGE_ID"'"
}
]
}' \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.heroku+json; version=3.docker_releases" \
-H "Authorization: Bearer $HEROKU_API_KEY"
This also unable to update my Heroku app with latest docker image (CURL result is HTTP 200OK, no error)
I'm expecting solution for executing last command heroku container:release web
to update my Heroku application within Bitbucket pipeline.