Skip to content

Commit 39f8001

Browse files
committed
CD pipeline added for Heroku and server hosted on various provider
1 parent 6cef222 commit 39f8001

File tree

3 files changed

+40
-18
lines changed

3 files changed

+40
-18
lines changed

.github/workflows/github-actions-CI-CD.yml

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ jobs:
4141
- name: Testing with pytest
4242
run: pytest -v -s
4343

44-
# - name: Login to Docker Hub
45-
# uses: docker/login-action@v3
46-
# with:
47-
# username: ${{ secrets.DOCKERHUB_USERNAME }}
48-
# password: ${{ secrets.DOCKERHUB_TOKEN }}
49-
# - name: Set up QEMU
50-
# uses: docker/setup-qemu-action@v3
51-
# - name: Set up Docker Buildx
52-
# uses: docker/setup-buildx-action@v3
53-
# - name: Build and push
54-
# uses: docker/build-push-action@v6
55-
# with:
56-
# context: .
57-
# push: true
58-
# tags: ${{ secrets.DOCKERHUB_USERNAME }}/fastapi_cicd:latest
44+
- name: Login to Docker Hub
45+
uses: docker/login-action@v3
46+
with:
47+
username: ${{ secrets.DOCKERHUB_USERNAME }}
48+
password: ${{ secrets.DOCKERHUB_TOKEN }}
49+
- name: Set up QEMU
50+
uses: docker/setup-qemu-action@v3
51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@v3
53+
- name: Build and push
54+
uses: docker/build-push-action@v6
55+
with:
56+
context: .
57+
push: true
58+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/fastapi_cicd:latest
5959

6060
CD:
6161
runs-on: ubuntu-latest
@@ -70,4 +70,25 @@ jobs:
7070
with:
7171
serviceId: ${{ secrets.RENDER_SERVICE_ID }}
7272
apiKey: ${{ secrets.RENDER_API_KEY }}
73-
multipleDeployment: false #optional, default true
73+
multipleDeployment: false
74+
75+
# - name: deployment on Heroku and install Heroku CLI
76+
# run: |
77+
# curl https://cli-assets.heroku.com/install.sh | sh
78+
# - uses: akhileshns/heroku-deploy@v3.14.15
79+
# with:
80+
# heroku_api_key: ${{secrets.HEROKU_API_KEY}}
81+
# heroku_app_name: ${{secrets.HEROKU_APP_NAME}}
82+
# heroku_email: ${{secrets.HEROKU_EMAIL}}
83+
84+
# - name: deploying to ubuntu server on AWS, AZURE, GCP, Digital Ocean and many more.
85+
# uses: appleboy/ssh-action@v1
86+
# with:
87+
# host: ${{ secrets.PROD_HOST }}
88+
# username: ${{ secrets.PROD_USERNAME }}
89+
# password: ${{ secrets.PROD_PASSWORD }}
90+
# port: ${{ secrets.PORT }}
91+
# script: |
92+
# cd app/src
93+
# git pull
94+
# echo ${{ secrets.PROD_PASSWORD }} | sudo -S systemctl restart api

app/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ async def lifespan(app: FastAPI):
2929

3030
@app.get("/")
3131
def read_root():
32-
return {"message": "Hello World Successfully deployed on Render via CICD"}
32+
return {"message": "Hello World successfully deployed on Render via CICD pipeline(Github Actions)"}

tests/test_users.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
def test_root(client: TestClient):
1111
res = client.get("/")
12-
assert res.json().get('message') == "Hello World Successfully deployed on Render via CICD"
12+
assert res.json().get(
13+
'message') == "Hello World successfully deployed on Render via CICD pipeline(Github Actions)"
1314

1415

1516
def test_create_user(session: Session, client: TestClient):

0 commit comments

Comments
 (0)