@@ -11,138 +11,29 @@ env:
1111 STAGE : production
1212
1313jobs :
14- build-and-publish-frontend :
15- name : Build and publish - Frontend
14+ build-and-publish :
15+ name : Build and publish -
1616 runs-on : ubuntu-latest
1717
18- steps :
19- - name : Checkout repository
20- uses : actions/checkout@v4
21- with :
22- ref : ${{ github.ref_name }}
23-
24- - name : Log in to the container registry
25- uses : docker/login-action@v3
26- with :
27- registry : ${{ env.REGISTRY }}
28- username : ${{ github.actor }}
29- password : ${{ secrets.GITHUB_TOKEN }}
30-
31- - name : Extract metadata for Docker
32- id : meta
33- uses : docker/metadata-action@v5
34- with :
35- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend
36- tags : |
37- type=ref,event=tag
38- type=sha
39- type=raw,value=${{ env.STAGE }}
40- latest
41- labels : |
42- stage=${{ env.STAGE }}
43-
44- - name : Build and Publish Docker Images
45- uses : docker/build-push-action@v5
46- with :
47- context : ./frontend
48- file : ./frontend/Dockerfile
49- push : true
50- tags : ${{ steps.meta.outputs.tags }}
51- labels : ${{ steps.meta.outputs.labels }}
52- build-args : |
53- STAGE=${{ env.STAGE }}
54-
55- build-and-publish-backend-api-gateway :
56- name : Build and publish - API Gateway
57- runs-on : ubuntu-latest
18+ strategy :
19+ matrix :
20+ service :
21+ - name : frontend
22+ context : ./frontend
23+ - name : api-gateway
24+ context : ./backend/api-gateway
25+ - name : api-composer
26+ context : ./backend/src/BIE.Core
27+ - name : datapipeline
28+ context : ./backend/src/BIE.DataPipeline
29+ - name : sql-database
30+ context : ./backend/sql-database
31+ - name : metadata-database
32+ context : ./backend/metadata-database
5833
5934 steps :
6035 - name : Checkout repository
6136 uses : actions/checkout@v4
62- with :
63- ref : ${{ github.ref_name }}
64-
65- - name : Log in to the container registry
66- uses : docker/login-action@v3
67- with :
68- registry : ${{ env.REGISTRY }}
69- username : ${{ github.actor }}
70- password : ${{ secrets.GITHUB_TOKEN }}
71-
72- - name : Extract metadata for Docker
73- id : meta
74- uses : docker/metadata-action@v5
75- with :
76- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-api-gateway
77- tags : |
78- type=ref,event=tag
79- type=sha
80- type=raw,value=${{ env.STAGE }}
81- latest
82- labels : |
83- stage=${{ env.STAGE }}
84-
85- - name : Build and Publish Docker Images
86- uses : docker/build-push-action@v5
87- with :
88- context : ./backend/src/BIE.Core
89- file : ./backend/src/BIE.Core/Dockerfile
90- push : true
91- tags : ${{ steps.meta.outputs.tags }}
92- labels : ${{ steps.meta.outputs.labels }}
93- build-args : |
94- STAGE=${{ env.STAGE }}
95-
96- build-and-publish-backend-datapipeline :
97- name : Build and publish - Data Pipeline
98- runs-on : ubuntu-latest
99-
100- steps :
101- - name : Checkout repository
102- uses : actions/checkout@v4
103- with :
104- ref : ${{ github.ref_name }}
105-
106- - name : Log in to the container registry
107- uses : docker/login-action@v3
108- with :
109- registry : ${{ env.REGISTRY }}
110- username : ${{ github.actor }}
111- password : ${{ secrets.GITHUB_TOKEN }}
112-
113- - name : Extract metadata for Docker
114- id : meta
115- uses : docker/metadata-action@v5
116- with :
117- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-datapipeline
118- tags : |
119- type=ref,event=tag
120- type=sha
121- type=raw,value=${{ env.STAGE }}
122- latest
123- labels : |
124- stage=${{ env.STAGE }}
125-
126- - name : Build and Publish Docker Images
127- uses : docker/build-push-action@v5
128- with :
129- context : ./backend/src/BIE.DataPipeline
130- file : ./backend/src/BIE.DataPipeline/Dockerfile
131- push : true
132- tags : ${{ steps.meta.outputs.tags }}
133- labels : ${{ steps.meta.outputs.labels }}
134- build-args : |
135- STAGE=${{ env.STAGE }}
136-
137- build-and-publish-backend-sql-database :
138- name : Build and publish - SQL Database
139- runs-on : ubuntu-latest
140-
141- steps :
142- - name : Checkout repository
143- uses : actions/checkout@v4
144- with :
145- ref : ${{ github.ref_name }}
14637
14738 - name : Log in to the container registry
14839 uses : docker/login-action@v3
@@ -151,11 +42,11 @@ jobs:
15142 username : ${{ github.actor }}
15243 password : ${{ secrets.GITHUB_TOKEN }}
15344
154- - name : Extract metadata for Docker
45+ - name : Extract metadata for Docker - ${{ matrix.service.name }}
15546 id : meta
15647 uses : docker/metadata-action@v5
15748 with :
158- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-sql-database
49+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.service.name }}
15950 tags : |
16051 type=ref,event=tag
16152 type=sha
@@ -164,25 +55,19 @@ jobs:
16455 labels : |
16556 stage=${{ env.STAGE }}
16657
167- - name : Build and Publish Docker Images
58+ - name : Build and Publish Docker Image - ${{ matrix.service.name }}
16859 uses : docker/build-push-action@v5
16960 with :
170- context : ./backend/database
171- file : ./backend/database /Dockerfile
61+ context : ${{ matrix.service.context }}
62+ file : ${{ matrix.service.context }} /Dockerfile
17263 push : true
17364 tags : ${{ steps.meta.outputs.tags }}
17465 labels : ${{ steps.meta.outputs.labels }}
17566 build-args : |
17667 STAGE=${{ env.STAGE }}
17768
178- deploy-prod-env :
179- needs :
180- [
181- build-and-publish-frontend,
182- build-and-publish-backend-api-gateway,
183- build-and-publish-backend-datapipeline,
184- build-and-publish-backend-sql-database,
185- ]
69+ deploy-test-env :
70+ needs : build-and-publish
18671 name : Deploy - Production Environment
18772 runs-on : ubuntu-latest
18873
20186 scp ./docker-compose.yml ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}}:/var/lib/bie
20287 scp ./.env.production ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}}:/var/lib/bie/.env
20388 - name : Connect and Pull
204- run : ssh ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}} "cd /var/lib/bie && docker compose pull && docker compose up -d --remove-orphans && exit"
89+ run : ssh ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}} "cd /var/lib/bie && docker compose down --remove-orphans && docker compose pull && docker compose up -d --remove-orphans && exit"
20590 - name : Cleanup
20691 run : rm -rf ~/.ssh
0 commit comments