Skip to content

Commit c3555f1

Browse files
r-p-alvessousadax12
andcommitted
feat: update cicd to deploy split into k8s (#1576)
Co-authored-by: joaosousa <[email protected]>
1 parent f76463d commit c3555f1

File tree

2 files changed

+49
-53
lines changed

2 files changed

+49
-53
lines changed

.github/workflows/deploy_backend_frontend.yml

+14-41
Original file line numberDiff line numberDiff line change
@@ -28,58 +28,33 @@ jobs:
2828
ROOT: ./frontend
2929
secrets: inherit
3030

31-
deploy_backend_dev:
32-
name: Deploy backend DEV
33-
needs: build_backend
34-
uses: ./.github/workflows/on_call_deploy.yaml
35-
with:
36-
ENVIRONMENT: dev
37-
APP_NAME: split-be-dev
38-
REPOSITORY: backend
39-
secrets:
40-
PUBLISH_PROFILE: ${{ secrets.AZURE_BACKEND_PUBLISH_PROFILE }}
41-
42-
deploy_frontend_dev:
43-
name: Deploy frontend DEV
44-
needs: build_frontend
31+
deploy_dev:
32+
name: Deploy DEV
33+
needs:
34+
- build_backend
35+
- build_frontend
4536
uses: ./.github/workflows/on_call_deploy.yaml
4637
with:
4738
ENVIRONMENT: dev
48-
APP_NAME: split-fe-dev
49-
REPOSITORY: frontend
50-
secrets:
51-
PUBLISH_PROFILE: ${{ secrets.AZURE_FRONTEND_PUBLISH_PROFILE }}
39+
CHART_OVERRIDE_PATH: './infrastructure/values/development.yaml'
40+
secrets: inherit
5241

53-
deploy_backend_prod:
54-
name: Deploy backend PROD
55-
needs: deploy_backend_dev
56-
uses: ./.github/workflows/on_call_deploy.yaml
57-
with:
58-
ENVIRONMENT: prod
59-
APP_NAME: split-be
60-
REPOSITORY: backend
61-
secrets:
62-
PUBLISH_PROFILE: ${{ secrets.AZURE_BACKEND_PUBLISH_PROFILE }}
6342

64-
deploy_frontend_prod:
65-
name: Deploy frontend PROD
66-
needs: deploy_frontend_dev
43+
deploy_prod:
44+
name: Deploy PROD
45+
needs: deploy_dev
6746
uses: ./.github/workflows/on_call_deploy.yaml
6847
with:
6948
ENVIRONMENT: prod
70-
APP_NAME: split-fe
71-
REPOSITORY: frontend
72-
secrets:
73-
PUBLISH_PROFILE: ${{ secrets.AZURE_FRONTEND_PUBLISH_PROFILE }}
49+
CHART_OVERRIDE_PATH: './infrastructure/values/production.yaml'
50+
secrets: inherit
7451

7552
pre_release:
7653
name: Create Pre Release
7754
runs-on: ubuntu-latest
7855
permissions:
7956
contents: write
80-
needs:
81-
- deploy_backend_dev
82-
- deploy_frontend_dev
57+
needs: deploy_dev
8358
steps:
8459
- name: Update release draft
8560
uses: release-drafter/release-drafter@v6
@@ -93,9 +68,7 @@ jobs:
9368
runs-on: ubuntu-latest
9469
permissions:
9570
contents: write
96-
needs:
97-
- deploy_backend_prod
98-
- deploy_frontend_prod
71+
needs: deploy_prod
9972
steps:
10073
- name: Update release draft
10174
uses: release-drafter/release-drafter@v6

.github/workflows/on_call_deploy.yaml

+35-12
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,49 @@ on:
66
ENVIRONMENT:
77
required: true
88
type: string
9-
APP_NAME:
9+
CHART_OVERRIDE_PATH:
1010
required: true
1111
type: string
12-
REPOSITORY:
13-
required: true
14-
type: string
15-
secrets:
16-
PUBLISH_PROFILE:
17-
required: true
1812

1913
env:
2014
TAG: ${{ github.sha }}
15+
CHART-PATH: './infrastructure/split'
2116

2217
jobs:
2318
deploy:
2419
runs-on: ubuntu-latest
25-
environment: ${{ inputs.ENVIRONMENT }}
2620
steps:
27-
- uses: azure/webapps-deploy@v3
21+
- name: Checkout code
22+
uses: actions/checkout@v2
23+
24+
- name: "check is AZURE_CREDENTIALS exists"
25+
env:
26+
super_secret: ${{ secrets.AZURE_CREDENTIALS }}
27+
if: ${{ env.super_secret == '' }}
28+
run: 'echo "echo the secret \"AZURE_CREDENTIALS\" has not been made; echo please go to \"settings \> secrets \> actions\" to create it"'
29+
30+
- name: Azure login
31+
uses: azure/login@v2
2832
with:
29-
app-name: ${{ inputs.APP_NAME }}
30-
publish-profile: ${{ secrets.PUBLISH_PROFILE }}
31-
images: split.azurecr.io/${{ inputs.REPOSITORY }}:${{ env.TAG }}
33+
creds: ${{ secrets.AZURE_CREDENTIALS }}
34+
35+
# Use kubelogin to configure your kubeconfig for Azure auth
36+
- name: Set up kubelogin for non-interactive login
37+
uses: azure/use-kubelogin@v1
38+
with:
39+
kubelogin-version: 'v0.0.25'
40+
41+
- name: Set AKS context
42+
uses: azure/aks-set-context@v4
43+
with:
44+
resource-group: '${{ secrets.RESOURCE_GROUP }}'
45+
cluster-name: '${{ secrets.CLUSTER_NAME }}'
46+
admin: 'false'
47+
use-kubelogin: 'true'
48+
49+
- name: Install Helm
50+
uses: azure/[email protected]
51+
52+
- name: Deploy
53+
#environment: ${{ inputs.ENVIRONMENT }}
54+
run: helm upgrade --install split ${{ env.CHART-PATH }} -f ${{ inputs.CHART_OVERRIDE_PATH }} --set global.image.tag=${{ env.TAG }} --namespace=split-${{ inputs.ENVIRONMENT }} --create-namespace --atomic

0 commit comments

Comments
 (0)