File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7070 run : docker exec fastapi-tdd python -m black . --check
7171 - name : isort
7272 run : docker exec fastapi-tdd python -m isort . --check-only
73+
74+ deploy :
75+ name : Deploy to Heroku
76+ runs-on : ubuntu-latest
77+ needs : [build, test]
78+ env :
79+ HEROKU_APP_NAME : thawing-beach-87010
80+ HEROKU_REGISTRY_IMAGE : registry.heroku.com/${HEROKU_APP_NAME}/summarizer
81+ steps :
82+ - name : Checkout master
83+ uses : actions/checkout@v2.3.4
84+ - name : Log in to GitHub Packages
85+ run : echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin docker.pkg.github.com
86+ env :
87+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
88+ - name : Pull image
89+ run : |
90+ docker pull ${{ env.IMAGE }}:latest || true
91+ - name : Build image
92+ run : |
93+ docker build \
94+ --cache-from ${{ env.IMAGE }}:latest \
95+ --tag ${{ env.HEROKU_REGISTRY_IMAGE }}:latest \
96+ --file ./project/Dockerfile.prod \
97+ "./project"
98+ - name : Log in to the Heroku Container Registry
99+ run : docker login -u _ -p ${HEROKU_AUTH_TOKEN} registry.heroku.com
100+ env :
101+ HEROKU_AUTH_TOKEN : ${{ secrets.HEROKU_AUTH_TOKEN }}
102+ - name : Push to the registry
103+ run : docker push ${{ env.HEROKU_REGISTRY_IMAGE }}
104+ - name : Set environment variables
105+ run : |
106+ echo "HEROKU_REGISTRY_IMAGE=${{ env.HEROKU_REGISTRY_IMAGE }}" >> $GITHUB_ENV
107+ echo "HEROKU_AUTH_TOKEN=${{ secrets.HEROKU_AUTH_TOKEN }}" >> $GITHUB_ENV
108+ - name : Release
109+ run : |
110+ chmod +x ./release.sh
111+ ./release.sh
Original file line number Diff line number Diff line change 1111@router .get ("/ping" )
1212async def pong (settings : Settings = Depends (get_settings )):
1313 return {
14- "ping" : "pong! " ,
14+ "ping" : "pong" ,
1515 "environment" : settings .environment ,
1616 "testing" : settings .testing ,
1717 }
Original file line number Diff line number Diff line change 44def test_ping (test_app ):
55 response = test_app .get ("/ping" )
66 assert response .status_code == 200
7- assert response .json () == {"environment" : "dev" , "ping" : "pong! " , "testing" : True }
7+ assert response .json () == {"environment" : "dev" , "ping" : "pong" , "testing" : True }
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ set -e
4+
5+ IMAGE_ID=$( docker inspect ${HEROKU_REGISTRY_IMAGE} --format={{.Id}})
6+ PAYLOAD=' {"updates": [{"type": "web", "docker_image": "' " $IMAGE_ID " ' "}]}'
7+
8+ curl -n -X PATCH https://api.heroku.com/apps/$HEROKU_APP_NAME /formation \
9+ -d " ${PAYLOAD} " \
10+ -H " Content-Type: application/json" \
11+ -H " Accept: application/vnd.heroku+json; version=3.docker-releases" \
12+ -H " Authorization: Bearer ${HEROKU_AUTH_TOKEN} "
You can’t perform that action at this time.
0 commit comments