-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vimal-knoldus
committed
Sep 23, 2023
1 parent
cae48f3
commit 8dc421d
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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----------" | ||
|