Skip to content

Commit

Permalink
feat: update cicd to deploy split into k8s (#1576)
Browse files Browse the repository at this point in the history
Co-authored-by: joaosousa <[email protected]>
  • Loading branch information
r-p-alves and sousadax12 committed Oct 18, 2024
1 parent f76463d commit c3555f1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 53 deletions.
55 changes: 14 additions & 41 deletions .github/workflows/deploy_backend_frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,58 +28,33 @@ jobs:
ROOT: ./frontend
secrets: inherit

deploy_backend_dev:
name: Deploy backend DEV
needs: build_backend
uses: ./.github/workflows/on_call_deploy.yaml
with:
ENVIRONMENT: dev
APP_NAME: split-be-dev
REPOSITORY: backend
secrets:
PUBLISH_PROFILE: ${{ secrets.AZURE_BACKEND_PUBLISH_PROFILE }}

deploy_frontend_dev:
name: Deploy frontend DEV
needs: build_frontend
deploy_dev:
name: Deploy DEV
needs:
- build_backend
- build_frontend
uses: ./.github/workflows/on_call_deploy.yaml
with:
ENVIRONMENT: dev
APP_NAME: split-fe-dev
REPOSITORY: frontend
secrets:
PUBLISH_PROFILE: ${{ secrets.AZURE_FRONTEND_PUBLISH_PROFILE }}
CHART_OVERRIDE_PATH: './infrastructure/values/development.yaml'
secrets: inherit

deploy_backend_prod:
name: Deploy backend PROD
needs: deploy_backend_dev
uses: ./.github/workflows/on_call_deploy.yaml
with:
ENVIRONMENT: prod
APP_NAME: split-be
REPOSITORY: backend
secrets:
PUBLISH_PROFILE: ${{ secrets.AZURE_BACKEND_PUBLISH_PROFILE }}

deploy_frontend_prod:
name: Deploy frontend PROD
needs: deploy_frontend_dev
deploy_prod:
name: Deploy PROD
needs: deploy_dev
uses: ./.github/workflows/on_call_deploy.yaml
with:
ENVIRONMENT: prod
APP_NAME: split-fe
REPOSITORY: frontend
secrets:
PUBLISH_PROFILE: ${{ secrets.AZURE_FRONTEND_PUBLISH_PROFILE }}
CHART_OVERRIDE_PATH: './infrastructure/values/production.yaml'
secrets: inherit

pre_release:
name: Create Pre Release
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- deploy_backend_dev
- deploy_frontend_dev
needs: deploy_dev
steps:
- name: Update release draft
uses: release-drafter/release-drafter@v6
Expand All @@ -93,9 +68,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- deploy_backend_prod
- deploy_frontend_prod
needs: deploy_prod
steps:
- name: Update release draft
uses: release-drafter/release-drafter@v6
Expand Down
47 changes: 35 additions & 12 deletions .github/workflows/on_call_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,49 @@ on:
ENVIRONMENT:
required: true
type: string
APP_NAME:
CHART_OVERRIDE_PATH:
required: true
type: string
REPOSITORY:
required: true
type: string
secrets:
PUBLISH_PROFILE:
required: true

env:
TAG: ${{ github.sha }}
CHART-PATH: './infrastructure/split'

jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.ENVIRONMENT }}
steps:
- uses: azure/webapps-deploy@v3
- name: Checkout code
uses: actions/checkout@v2

- name: "check is AZURE_CREDENTIALS exists"
env:
super_secret: ${{ secrets.AZURE_CREDENTIALS }}
if: ${{ env.super_secret == '' }}
run: 'echo "echo the secret \"AZURE_CREDENTIALS\" has not been made; echo please go to \"settings \> secrets \> actions\" to create it"'

- name: Azure login
uses: azure/login@v2
with:
app-name: ${{ inputs.APP_NAME }}
publish-profile: ${{ secrets.PUBLISH_PROFILE }}
images: split.azurecr.io/${{ inputs.REPOSITORY }}:${{ env.TAG }}
creds: ${{ secrets.AZURE_CREDENTIALS }}

# Use kubelogin to configure your kubeconfig for Azure auth
- name: Set up kubelogin for non-interactive login
uses: azure/use-kubelogin@v1
with:
kubelogin-version: 'v0.0.25'

- name: Set AKS context
uses: azure/aks-set-context@v4
with:
resource-group: '${{ secrets.RESOURCE_GROUP }}'
cluster-name: '${{ secrets.CLUSTER_NAME }}'
admin: 'false'
use-kubelogin: 'true'

- name: Install Helm
uses: azure/[email protected]

- name: Deploy
#environment: ${{ inputs.ENVIRONMENT }}
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 comments on commit c3555f1

Please sign in to comment.