From d7cbf4142ea716fa2c36f796f4deef45abb1135f Mon Sep 17 00:00:00 2001 From: Tommy Parnell Date: Mon, 20 Jun 2022 11:39:38 -0400 Subject: [PATCH] Create an auto-deploy file --- ...r-b75dfe37-07c8-4654-a996-77591661b188.yml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/code-server-app-AutoDeployTrigger-b75dfe37-07c8-4654-a996-77591661b188.yml diff --git a/.github/workflows/code-server-app-AutoDeployTrigger-b75dfe37-07c8-4654-a996-77591661b188.yml b/.github/workflows/code-server-app-AutoDeployTrigger-b75dfe37-07c8-4654-a996-77591661b188.yml new file mode 100644 index 0000000..6461659 --- /dev/null +++ b/.github/workflows/code-server-app-AutoDeployTrigger-b75dfe37-07c8-4654-a996-77591661b188.yml @@ -0,0 +1,60 @@ +name: Trigger auto deployment for code-server-app + +# When this action will be executed +on: + # Automatically trigger it when detected changes in repo + push: + branches: + [ main ] + paths: + - '**' + - '.github/workflows/code-server-app-AutoDeployTrigger-b75dfe37-07c8-4654-a996-77591661b188.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: terribledevreg.azurecr.io + username: ${{ secrets.CODESERVERAPP_REGISTRY_USERNAME }} + password: ${{ secrets.CODESERVERAPP_REGISTRY_PASSWORD }} + + - name: Build and push container image to registry + uses: docker/build-push-action@v2 + with: + push: true + tags: terribledevreg.azurecr.io/code-server-app:${{ github.sha }} + file: ./Dockerfile + context: ./ + + + deploy: + runs-on: ubuntu-latest + needs: build + + steps: + - name: Azure Login + uses: azure/login@v1 + with: + creds: ${{ secrets.CODESERVERAPP_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 code-server-app -g code-server-app --server terribledevreg.azurecr.io --username ${{ secrets.CODESERVERAPP_REGISTRY_USERNAME }} --password ${{ secrets.CODESERVERAPP_REGISTRY_PASSWORD }} + az containerapp update -n code-server-app -g code-server-app --image terribledevreg.azurecr.io/code-server-app:${{ github.sha }}