Skip to content

Main #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Trigger auto deployment for my-container-app

# When this action will be executed
on:
# Automatically trigger it when detected changes in repo
push:
branches:
[ main ]
paths:
- '**'
- '.github/workflows/my-container-app-AutoDeployTrigger-aa29795c-c39b-4ce3-8c6f-cadf763022df.yml'

# 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 container registry
uses: docker/login-action@v1
with:
registry: mycontainerkarim.azurecr.io
username: ${{ secrets.MYCONTAINERAPP_REGISTRY_USERNAME }}
password: ${{ secrets.MYCONTAINERAPP_REGISTRY_PASSWORD }}

- name: Build and push container image to registry
uses: docker/build-push-action@v2
with:
push: true
tags: mycontainerkarim.azurecr.io/my-container-app:${{ github.sha }}
file: ./Dockerfile
context: ./


deploy:
runs-on: ubuntu-latest
needs: build

steps:
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.MYCONTAINERAPP_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 my-container-app -g rg-my-container-apps --server mycontainerkarim.azurecr.io --username ${{ secrets.MYCONTAINERAPP_REGISTRY_USERNAME }} --password ${{ secrets.MYCONTAINERAPP_REGISTRY_PASSWORD }}
az containerapp update -n my-container-app -g rg-my-container-apps --image mycontainerkarim.azurecr.io/my-container-app:${{ github.sha }}