Skip to content

Switched to python 3.11 image, removed microconda #3

Switched to python 3.11 image, removed microconda

Switched to python 3.11 image, removed microconda #3

name: Trigger auto deployment for demotranslate
# When this action will be executed
on:
# Automatically trigger it when detected changes in repo
push:
branches: [main, refactor]
paths:
- "**"
- ".github/workflows/AutoDeploy.yml"
# Allow mannually trigger
workflow_dispatch:
env:
REGISTRY_NAME: heinousacr
REPOSITORY_NAME: demotranslate-ui
RESOURCE_GROUP: translation-ui
# CONTAINER_APP_NAME: demotranslate-ui
WEB_APP_NAME: demotranslate-ui
KEYVAULT_NAME: translation-ui-kv
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout to the branch
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
# https://stackoverflow.com/questions/74209048/key-vault-secrets-in-github-actions-workflow#:~:text=I%20could%20use%20the%20action%20to%20access%20the,secret%20show%20--vault-name%20MyVaultName%20--name%20MySecret%20--query%20value
- name: Get Registry Secrets via Azure CLI
uses: azure/CLI@v1
with:
azcliversion: 2.51.0
inlineScript: |
echo registry_username=$(az keyvault secret show --vault-name ${{env.KEYVAULT_NAME}} --name registryusername --query value --out tsv) >> "$GITHUB_ENV"
echo registry_password=$(az keyvault secret show --vault-name ${{env.KEYVAULT_NAME}} --name registrypassword --query value --out tsv) >> "$GITHUB_ENV"
- name: Log in to container registry
uses: azure/docker-login@v1
with:
login-server: ${{env.REGISTRY_NAME}}.azurecr.io
username: ${{ env.registry_username }}
password: ${{ env.registry_password }}
- name: Build and push container image to registry
uses: docker/build-push-action@v2
with:
push: true
tags: ${{env.REGISTRY_NAME}}.azurecr.io/${{env.REPOSITORY_NAME}}:${{ github.sha }}
file: ./Dockerfile
context: ./
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
# - name: Deploy to containerapp
# uses: azure/CLI@v1
# with:
# inlineScript: |
# az config set extension.use_dynamic_install=yes_without_prompt
# az containerapp registry set -n ${{env.CONTAINER_APP_NAME}} -g ${{env.RESOURCE_GROUP}} --server ${{env.REGISTRY_NAME}}.azurecr.io --username ${{ env.registry_username }} --password ${{ env.registry_password }}
# az containerapp update -n ${{env.CONTAINER_APP_NAME}} -g ${{env.RESOURCE_GROUP}} --image ${{env.REGISTRY_NAME}}.azurecr.io/${{env.REPOSITORY_NAME}}:${{ github.sha }}
- uses: azure/webapps-deploy@v2
with:
app-name: "${{env.WEB_APP_NAME}}"
images: "${{env.REGISTRY_NAME}}.azurecr.io/${{env.REPOSITORY_NAME}}:${{ github.sha }}"