Skip to content

Commit 222d0c5

Browse files
authored
Merge pull request #140 from mohammadll/master
Add CICD workflow for the backend app
2 parents 935a2a4 + d751d41 commit 222d0c5

File tree

6 files changed

+95
-69
lines changed

6 files changed

+95
-69
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/cicd.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Realse Version
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- dev
8+
paths:
9+
- 'app/**'
10+
- 'crawl/**'
11+
12+
jobs:
13+
releaseGithub:
14+
if: github.ref == 'refs/heads/master'
15+
runs-on: ubuntu-22.04
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
steps:
20+
- name: Bump version and push tag
21+
id: bump
22+
uses: mathieudutour/[email protected]
23+
with:
24+
github_token: ${{ secrets.GITHUB_TOKEN }}
25+
default_bump: patch
26+
27+
- name: Build Changelog
28+
id: github_release
29+
uses: mikepenz/release-changelog-builder-action@v5
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
fromTag: ${{ steps.bump.outputs.previous_tag }}
33+
toTag: ${{ steps.bump.outputs.new_tag }}
34+
35+
- name: Create Release
36+
uses: softprops/action-gh-release@v2
37+
with:
38+
body: ${{ steps.bump.outputs.changelog }}
39+
tag_name: ${{ steps.bump.outputs.new_tag }}
40+
41+
releaseDockerWithDeployment:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v3
46+
47+
- name: Log in to DockerHub
48+
uses: docker/login-action@v2
49+
with:
50+
username: ${{ secrets.DOCKER_USERNAME }}
51+
password: ${{ secrets.DOCKER_PASSWORD }}
52+
53+
- name: Build and Push Docker Image
54+
uses: docker/build-push-action@v5
55+
with:
56+
context: .
57+
push: true
58+
tags: |
59+
${{ secrets.DOCKER_USERNAME }}/devopsgpt-fastapi:${{ github.ref_name }}
60+
61+
- name: Deploying landing prod on the remote server
62+
if: github.ref == 'refs/heads/master'
63+
uses: appleboy/[email protected]
64+
with:
65+
host: ${{ secrets.HOST }}
66+
username: ${{ secrets.HOST_USERNAME }}
67+
password: ${{ secrets.HOST_PASSWORD }}
68+
port: ${{ secrets.HOST_PORT }}
69+
script: docker compose -f devopsgpt-fastapi/docker-compose-fastapi.yml down fastapi_prod && docker compose -f devopsgpt-fastapi/docker-compose-fastapi.yml up -d --pull always fastapi_prod
70+
71+
- name: Deploying landing dev on the remote server
72+
if: github.ref == 'refs/heads/dev'
73+
uses: appleboy/[email protected]
74+
with:
75+
host: ${{ secrets.HOST }}
76+
username: ${{ secrets.HOST_USERNAME }}
77+
password: ${{ secrets.HOST_PASSWORD }}
78+
port: ${{ secrets.HOST_PORT }}
79+
script: docker compose -f devopsgpt-fastapi/docker-compose-fastapi.yml down fastapi_dev && docker compose -f devopsgpt-fastapi/docker-compose-fastapi.yml up -d --pull always fastapi_dev
80+
81+
- name: Removing dangle images on the remote server
82+
uses: appleboy/[email protected]
83+
with:
84+
host: ${{ secrets.HOST }}
85+
username: ${{ secrets.HOST_USERNAME }}
86+
password: ${{ secrets.HOST_PASSWORD }}
87+
port: ${{ secrets.HOST_PORT }}
88+
script: docker image prune -f

.github/workflows/unit-test.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ jobs:
2020
- name: install requirements
2121
run: pip install -r requirements.txt
2222

23-
- name: docker login
24-
uses: docker/login-action@v3
25-
with:
26-
username: 81318131
27-
password: ${{ secrets.DOCKER_PASSWORD }}
2823

2924
- name: build services
3025
run: docker compose build

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
namespace ?= default
22
releaseName ?= devopsgpt
33

4-
all: build up
4+
all: update-submodule build up
5+
6+
update-submodule:
7+
git submodule init && git submodule update
58

69
build:
710
docker compose build

app/tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def client():
1919
return TestClient(app)
2020

2121

22+
2223
@pytest.fixture
2324
def iac_template_docker_sample_input():
2425
return IaCTemplateGenerationDocker().model_dump()

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
build:
66
context: .
77
dockerfile: Dockerfile
8-
image: 81318131/fastapi_gpt
8+
image: fastapi_gpt
99
container_name: fastapi_gpt
1010
command: fastapi run app/main.py --port 8080
1111
volumes:
@@ -24,7 +24,7 @@ services:
2424
dockerfile: Dockerfile
2525
args:
2626
VITE_API_CLIENT_BASE_URL: "http://localhost:8080/api/"
27-
image: 81318131/web_gpt
27+
image: web_gpt
2828
container_name: web_gpt
2929
ports:
3030
- "80:4173"

0 commit comments

Comments
 (0)