Trigger auto deployment for demo-container #6
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
name: Trigger auto deployment for demo-container | |
env: | |
AZURE_CONTAINER_APP_NAME: demo-container | |
AZURE_GROUP_NAME: demo-container | |
# When this action will be executed | |
on: | |
# Automatically trigger it when detected changes in repo. Remove comments to enable | |
#push: | |
# branches: | |
# [ main ] | |
# Allow mannually trigger | |
workflow_dispatch: | |
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 GitHub container registry | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Lowercase the repo name and username | |
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} | |
- name: Build and push container image to registry | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
tags: ghcr.io/${{ env.REPO }}:${{ github.sha }} | |
file: ./Dockerfile | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Azure Login | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Lowercase the repo name and username | |
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} | |
- 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.AZURE_CONTAINER_APP_NAME }} -g ${{ env.AZURE_GROUP_NAME }} --server ghcr.io --username ${{ github.actor }} --password ${{ secrets.PAT }} | |
az containerapp update -n ${{ env.AZURE_CONTAINER_APP_NAME }} -g ${{ env.AZURE_GROUP_NAME }} --set-env-vars OPENAI_API_TYPE=azure OPENAI_API_BASE=https://demo-alfredo-openai.openai.azure.com/ OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} OPENAI_API_VERSION="2023-07-01-preview" SEARCH_SERVICE_NAME="https://demo-alfredo.search.windows.net" SEARCH_API_KEY=${{ secrets.AZURE_COGNITIVE_SEARCH_API_KEY }} SEARCH_INDEX_NAME="demo-alfredo" | |
az containerapp update -n demo-container -g demo-container --cpu 2 --memory 4Gi | |
az containerapp update -n ${{ env.AZURE_CONTAINER_APP_NAME }} -g ${{ env.AZURE_GROUP_NAME }} --image ghcr.io/${{ env.REPO }}:${{ github.sha }} |