Skip to content

Update container_apps_chat_cd.yml #39

Update container_apps_chat_cd.yml

Update container_apps_chat_cd.yml #39

name: Chat - Publish Docker Image
on:
push:
tags:
- "release-chat-v*.*.*"
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
env:
MSSQL_SA_PASSWORD: 6efe173b-3e33-4d6c-8f50-3e5f7cadd54c
TEST_DIRECTORY: tests/container_apps/Jordnaer.Chat.Tests
services:
mssql:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
SA_PASSWORD: "${{ env.MSSQL_SA_PASSWORD }}"
ACCEPT_EULA: 'Y'
ports:
- 1433:1433
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.x'
- name: Test
run: dotnet test "${{ env.TEST_DIRECTORY }}" --filter Category!=ManualTest
env:
ConnectionStrings__AppConfig: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}
ConnectionStrings__JordnaerDbContext: "Server=localhost,1433;Database=jordnaer;User ID=sa;Password=${{ env.MSSQL_SA_PASSWORD }};Persist Security Info=False;TrustServerCertificate=true;"
push:
if: |
always() &&
(needs.test.result == 'success' || needs.test.result == 'skipped')
needs: [test]
runs-on: ubuntu-latest
env:
DOCKER_IMAGE_NAME: chat
steps:
- name: Checkout code
uses: actions/checkout@v4
# Apply tags and labels based on GitHub Actions events and Git metadata
- name: Apply Docker Image tags & labels
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository_owner }}/${{ env.DOCKER_IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=ref,event=pr
type=match,pattern=v(.*),group=1
type=match,pattern=v(\d.\d),group=1
type=match,pattern=v(\d),group=1
type=sha,prefix=
type=sha,prefix=,format=long
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
context: .
file: ./src/container_apps/Jordnaer.Chat/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.CHAT_AZURE_CREDENTIALS }}
- name: Deploy image to Azure Container Apps
uses: azure/container-apps-deploy-action@v1
with:
containerAppName: chat
resourceGroup: Jordnaer
imageToDeploy: ghcr.io/nielspilgaard/chat:${{ github.sha }}