Skip to content

fix the fix the fix the fix the fix the fix the fix the fix the fix t… #106

fix the fix the fix the fix the fix the fix the fix the fix the fix t…

fix the fix the fix the fix the fix the fix the fix the fix the fix t… #106

name: Build and deploy soemi-weather microservices to AKS
on:
push:
branches: [ "main" ]
workflow_dispatch:
env:
AZURE_CONTAINER_REGISTRY: ""
CONTAINER_NAME: ""
RESOURCE_GROUP: ""
CLUSTER_NAME: ""
DEPLOYMENT_MANIFEST_PATH: ""
jobs:
build-images:
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get Short Commit SHA
run: |
echo "COMMIT_SHA_SHORT=$(echo ${{ github.sha }} | cut -c1-7)"
echo "COMMIT_SHA_SHORT=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
- name: Build docker images
run: |
echo "Building images"
docker build -t z100/soemi-woeb:${{ env.COMMIT_SHA_SHORT }} ./soemi-woeb
docker build -t z100/soemi-woers:${{ env.COMMIT_SHA_SHORT }} ./soemi-woers
- name: Push docker images
run: |
echo "Login to dockerhub"
docker login -u ${{ secrets.DOCKERHUB_U }} -p ${{ secrets.DOCKERHUB_T }}
echo "Pushing images"
docker push z100/soemi-woeb:${{ env.COMMIT_SHA_SHORT }}
docker push z100/soemi-woers:${{ env.COMMIT_SHA_SHORT }}
deploy-services:
permissions:
actions: read
contents: read
id-token: write
runs-on: ubuntu-latest
needs: [ build-images ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get Short Commit SHA
run: |
echo "COMMIT_SHA_SHORT=$(echo ${{ github.sha }} | cut -c1-7)"
echo "COMMIT_SHA_SHORT=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
- name: Populate deployment.yaml with vars
run: |
sed -i "s|\$IMAGE_TAG|${{ env.COMMIT_SHA_SHORT }}|g" ./soemi-woeb/k8s/deployment.yaml
sed -i "s|\$IMAGE_TAG|${{ env.COMMIT_SHA_SHORT }}|g" ./soemi-woers/k8s/deployment.yaml
- name: Azure login
uses: azure/login@v1.4.6
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Setup kubectl
uses: azure/setup-kubectl@v2.0
- name: Set AKS credentials
run: |
az aks get-credentials --resource-group ${{ secrets.RESOURCE_GROUP }} --name ${{ secrets.CLUSTER_NAME }} --overwrite-existing
- name: Set kubectl context
run: |
kubectl config use-context ${{ secrets.CLUSTER_NAME }}
- name: Deploy microservices to AKS
run: |
echo "Deploying services"
kubectl replace --force -f ./soemi-woeb/k8s
kubectl replace --force -f ./soemi-woers/k8s