Skip to content

Commit 779088c

Browse files
committed
updates
1 parent 0e86ab5 commit 779088c

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

.github/workflows/main.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,44 @@ jobs:
7575
run: docker exec fastapi-tdd python -m black . --check
7676
- name: isort
7777
run: docker exec fastapi-tdd python -m isort . --check-only
78+
79+
deploy:
80+
name: Deploy to Heroku
81+
runs-on: ubuntu-latest
82+
needs: [build, test]
83+
env:
84+
HEROKU_APP_NAME: shrouded-shelf-89730
85+
HEROKU_REGISTRY_IMAGE: registry.heroku.com/${HEROKU_APP_NAME}/summarizer
86+
steps:
87+
- name: Checkout
88+
uses: actions/checkout@v3
89+
with:
90+
ref: updates
91+
- name: Log in to GitHub Packages
92+
run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin ghcr.io
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
- name: Pull image
96+
run: |
97+
docker pull ${{ env.IMAGE }}:latest || true
98+
- name: Build image
99+
run: |
100+
docker build \
101+
--cache-from ${{ env.IMAGE }}:latest \
102+
--tag ${{ env.HEROKU_REGISTRY_IMAGE }}:latest \
103+
--file ./project/Dockerfile.prod \
104+
"./project"
105+
- name: Log in to the Heroku Container Registry
106+
run: docker login -u _ -p ${HEROKU_AUTH_TOKEN} registry.heroku.com
107+
env:
108+
HEROKU_AUTH_TOKEN: ${{ secrets.HEROKU_AUTH_TOKEN }}
109+
- name: Push to the registry
110+
run: docker push ${{ env.HEROKU_REGISTRY_IMAGE }}
111+
- name: Set environment variables
112+
run: |
113+
echo "HEROKU_REGISTRY_IMAGE=${{ env.HEROKU_REGISTRY_IMAGE }}" >> $GITHUB_ENV
114+
echo "HEROKU_AUTH_TOKEN=${{ secrets.HEROKU_AUTH_TOKEN }}" >> $GITHUB_ENV
115+
- name: Release
116+
run: |
117+
chmod +x ./release.sh
118+
./release.sh

project/app/api/ping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@router.get("/ping")
99
async def pong(settings: Settings = Depends(get_settings)):
1010
return {
11-
"ping": "pong!",
11+
"ping": "pong",
1212
"environment": settings.environment,
1313
"testing": settings.testing,
1414
}

project/tests/test_ping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
def test_ping(test_app):
22
response = test_app.get("/ping")
33
assert response.status_code == 200
4-
assert response.json() == {"environment": "dev", "ping": "pong!", "testing": True}
4+
assert response.json() == {"environment": "dev", "ping": "pong", "testing": True}

0 commit comments

Comments
 (0)