Updated workflow to deploy to AKS 2 #9
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
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: .NET | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
generate-version: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Github Tag Bump | |
id: tab_bump | |
uses: anothrNick/github-tag-action@1.67.0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
INITIAL_VERSION: 1.0.2 | |
DEFAULT_BUMP: patch | |
outputs: | |
new_version: ${{ steps.tab_bump.outputs.new_tag }} | |
build-and-deploy-service: | |
runs-on: ubuntu-latest | |
needs: generate-version | |
env: | |
APP_NAME: iga1playeconomy | |
SERVICE_NAME: trading | |
HELM_CHART_VERSION: 0.1.0 | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Azure Login | |
uses: Azure/login@v1.6.1 | |
with: | |
# ClientId of the Azure Service principal created. | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
# TenantId of the Azure Service principal created. | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
# Azure subscriptionId | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Login to container registry | |
run: az acr login --name ${{ env.APP_NAME }} | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v5.1.0 | |
with: | |
# List of secrets to expose to the build (e.g., key=string, GIT_AUTH_TOKEN=mytoken) | |
secrets: | | |
"GH_OWNER=${{github.repository_owner}}" | |
"GH_PAT=${{secrets.GH_PAT}}" | |
# List of tags | |
tags: ${{env.APP_NAME}}.azurecr.io/play.trading:${{ needs.generate-version.outputs.new_version }} | |
push: true | |
- name: Get AKS Credentials | |
run: az aks get-credentials --resource-group ${{ env.APP_NAME }} --name ${{ env.APP_NAME }} | |
- name: Helm tool installer | |
uses: Azure/setup-helm@v3 | |
- name: Login to Helm registry | |
run: | | |
helmUser=00000000-0000-0000-0000-000000000000 | |
helmPassword=$(az acr login --name ${{ env.APP_NAME }} --expose-token --output tsv --query accessToken) | |
helm registry login ${{ env.APP_NAME }}.azurecr.io --username $helmUser --password $helmPassword | |
env: | |
HELM_EXPERIMENTAL_OCI: 1 | |
- name: Deploy Helm chart | |
run: | | |
helm upgrade \ | |
${{ env.SERVICE_NAME }}-service \ | |
oci://${{ env.APP_NAME }}.azurecr.io/helm/microservice \ | |
--version ${{ env.HELM_CHART_VERSION }} \ | |
-f helm/values.yaml \ | |
-n ${{ env.SERVICE_NAME }} \ | |
--set image.tag=${{ needs.generate-version.outputs.new_version }} \ | |
--install \ | |
--wait | |
env: | |
HELM_EXPERIMENTAL_OCI: 1 |