Build and deploy .NET application to container app discordbotabordelv2-app-20230528 #14
Workflow file for this run
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: Build and deploy .NET application to container app discordbotabordelv2-app-20230528 | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
DOCKER_FILE_PATH: ./Discord.BotABordelV2/Dockerfile | |
PROJECT_NAME_FOR_DOCKER: discordbotabordelv2 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: PROD | |
steps: | |
- name: Checkout to the branch | |
uses: actions/checkout@v3 | |
- name: "Login via Azure CLI" | |
uses: azure/login@v1 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID}} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID}} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID}} | |
- name: Build and push container image to registry | |
uses: azure/CLI@v1 | |
with: | |
inlineScript: > | |
az acr build -t ${{ vars.CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.PROJECT_NAME_FOR_DOCKER }}:${{ github.event.release.tag_name }} -t ${{ vars.CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.PROJECT_NAME_FOR_DOCKER }}:latest --registry ${{ vars.CONTAINER_REGISTRY_LOGIN_SERVER }} --file ${{ env.DOCKER_FILE_PATH }} . | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
environment: PROD | |
steps: | |
- name: Azure Login | |
uses: azure/login@v1 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID}} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID}} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID}} | |
- name: Deploy to containerapp | |
uses: azure/CLI@v1 | |
with: | |
inlineScript: > | |
az config set extension.use_dynamic_install=yes_without_prompt | |
az containerapp registry set --name ${{ vars.CONTAINER_APP_NAME }} --resource-group ${{ vars.CONTAINER_APP_RESOURCE_GROUP_NAME }} --server ${{ vars.CONTAINER_REGISTRY_LOGIN_SERVER }} --username ${{ secrets.DiscordBotABordelV220230528141555_USERNAME_BE64 }} --password ${{ secrets.DiscordBotABordelV220230528141555_PASSWORD_BE64 }} | |
az containerapp update --name ${{ vars.CONTAINER_APP_NAME }} --container-name ${{ vars.CONTAINER_APP_CONTAINER_NAME }} --resource-group ${{ vars.CONTAINER_APP_RESOURCE_GROUP_NAME }} --image ${{ vars.CONTAINER_REGISTRY_LOGIN_SERVER }}/${{ env.PROJECT_NAME_FOR_DOCKER }}:${{ github.ref_name }} | |
- name: logout | |
run: > | |
az logout |