Skip to content

v0.2.4 Fix wrong env variable for db #6

v0.2.4 Fix wrong env variable for db

v0.2.4 Fix wrong env variable for db #6

name: Release Microservices
on:
release:
types:
- "released"
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }}-release
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
environment: production
strategy:
matrix:
app: [advertisements, accounts, gateway]
steps:
- uses: actions/checkout@v4
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true
- name: Build image on ACR
uses: azure/CLI@v1
with:
inlineScript: |
az configure --defaults acr=${{ vars.AZURE_CONTAINER_REGISTRY }}
az acr build -t ${{ vars.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ vars.AZURE_PROJECT_NAME }}-${{ matrix.app }}:${{ github.event.release.tag_name }} -r ${{ vars.AZURE_CONTAINER_REGISTRY }} ./apps/${{ matrix.app }}/
deploy:
needs: build
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Gets K8s context
id: context
uses: azure/aks-set-context@v3
with:
resource-group: ${{ vars.AZURE_RESOURCE_GROUP }}
cluster-name: ${{ vars.AZURE_CLUSTER_NAME }}
- name: Delete gateway secrets
continue-on-error: true
run: kubectl delete secret gateway-secrets
- name: Delete accounts secrets
continue-on-error: true
run: kubectl delete secret account-service-secrets
- name: Delete advertisements secrets
continue-on-error: true
run: kubectl delete secret advertisement-service-secrets
- name: Set secrets
run: |
kubectl create secret generic gateway-secrets \
--from-literal=ALLOWED_ORIGIN="sq.rikdenbreejen.nl"
kubectl create secret generic account-service-secrets \
--from-literal=DATABASE_USER="${{ secrets.DB_ADMIN_USER }}@squaremarket-accounts" \
--from-literal=DATABASE_PASSWORD="${{ secrets.DB_ADMIN_PASSWORD }}" \
--from-literal=DATABASE_HOST="${{ vars.ACCOUNTS_DB_HOST }}" \
--from-literal=DATABASE_PORT="3306" \
--from-literal=DATABASE_NAME="accounts"
kubectl create secret generic advertisement-service-secrets \
--from-literal=DATABASE_USER="${{ secrets.DB_ADMIN_USER }}@squaremarket-advertisements" \
--from-literal=DATABASE_PASSWORD="${{ secrets.DB_ADMIN_PASSWORD }}" \
--from-literal=DATABASE_HOST="${{ vars.ADVERTISEMENTS_DB_HOST }}" \
--from-literal=DATABASE_PORT="3306" \
--from-literal=DATABASE_NAME="advertisements"
- name: Deploys application
uses: Azure/k8s-deploy@v4
with:
manifests: |
k8s/azure-gateway-ingress.yml
k8s/gateway-deployment.yml
k8s/account-deployment.yml
k8s/advertisement-deployment.yml
k8s/message-queue-deployment.yml
images: |
${{ vars.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ vars.AZURE_PROJECT_NAME }}-gateway:${{ github.event.release.tag_name }}
${{ vars.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ vars.AZURE_PROJECT_NAME }}-accounts:${{ github.event.release.tag_name }}
${{ vars.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ vars.AZURE_PROJECT_NAME }}-advertisements:${{ github.event.release.tag_name }}
imagepullsecrets: |
${{ vars.PROJECT_NAME }}