Skip to content

Commit

Permalink
Azure pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
vimal-knoldus committed Sep 23, 2023
1 parent cae48f3 commit 8dc421d
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/car-demo-azure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: car-demo-common-service

on:
push:
branches: [ main ]
env:
AKS_CLUSTER: ntdemocluster
AKS_NAMESPACE: default

jobs:
setup-build-publish-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 19
uses: actions/setup-java@v3
with:
java-version: '19'
distribution: 'temurin'
cache: maven
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Azure CLI script
uses: azure/CLI@v1
with:
azcliversion: 2.30.0
inlineScript: |
az account show
az storage -h
- name: Build, Publish, and Deploy
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
. az-svc-deployment.sh
30 changes: 30 additions & 0 deletions az-svc-deployment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

AKS_CLUSTER="ntdemocluster"
SERVICE_NAME="admin-service"
DEPLOYMENT_NAME="admin-service"
RESOURCE_GROUP_NAME="az-nashtech-resource-group"

az aks install-cli
echo "---------build and deploy $SERVICE_NAME-----------"
cd "$SERVICE_NAME" || exit
mvn clean install
echo "---------packaging done, start docker build-----------"
docker build -f Dockerfile --tag gcr.io/"$SERVICE_NAME":"$GITHUB_SHA" .
echo "--------docker build done, docker push---------------"
docker push gcr.io/"$SERVICE_NAME":"$GITHUB_SHA"
echo "--------pushed docker image, deploy to aks cluster--------------------------"

az aks get-credentials --resource-group "$RESOURCE_GROUP_NAME" --name "$AKS_CLUSTER"
# setup kustomize
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
chmod u+x ./kustomize

# set docker image for kustomize
./kustomize edit set image gcr.io/IMAGE:TAG=gcr.io/"$SERVICE_NAME":"$GITHUB_SHA"
# deploy through kubectl
./kustomize build . | kubectl apply -f -
kubectl rollout status deployment/"$DEPLOYMENT_NAME"
kubectl get services -o wide
echo "-------------$SERVICE_NAME deployed on $CLUSTER_NAME----------"

0 comments on commit 8dc421d

Please sign in to comment.