Skip to content

.github/workflows/azure_container_setup_alvtime-test.yml #47

.github/workflows/azure_container_setup_alvtime-test.yml

.github/workflows/azure_container_setup_alvtime-test.yml #47

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy container app to Azure Web App - alvtime-test
on:
workflow_dispatch:
push:
branches:
- master
paths:
- "packages/api/**"
jobs:
build:
runs-on: 'ubuntu-latest'
environment: test
steps:
- uses: actions/checkout@main
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to registry
uses: docker/login-action@v2
with:
registry: https://commoninfrastructuretest.azurecr.io/
username: ${{ vars.AzureAppService_ContainerUsername_11510f2f6bf64633a871f60eed2d4625 }}
password: ${{ secrets.AzureAppService_ContainerPassword_dcfd19edf6f3408abde7828a7c85ecb8 }}
- name: Build and push container image to registry
uses: docker/build-push-action@v3
with:
context: ./packages/api/
push: true
tags: commoninfrastructuretest.azurecr.io/alvtimewebapi:${{ github.sha }}
file: ./packages/api/Dockerfile
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: test
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- uses: azure/login@v1
with:
creds: '${{ secrets.GITHUBACTIONDEPLOYMENTCREDENTIALS }}'
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'alvtime-test'
slot-name: 'production'
images: 'commoninfrastructuretest.azurecr.io/alvtimewebapi:${{ github.sha }}'
- uses: Azure/get-keyvault-secrets@v1
with:
keyvault: "k8sconfig-test-kv"
secrets: 'sql-connection-string'
id: myGetSecretAction
- name: Set appsettings
uses: Azure/appservice-settings@v1
with:
app-name: 'alvtime-test'
slot-name: 'production'
app-settings-json: '${{ vars.Api_AppSettings }}'
- name: Set appsettings from keyvault
uses: Azure/appservice-settings@v1
with:
app-name: 'alvtime-test'
slot-name: 'production'
app-settings-json: '[{"name": "ConnectionStrings__AlvTime_db", "value": "${{ steps.myGetSecretAction.outputs.sql-connection-string }}"}]'