-
-
Notifications
You must be signed in to change notification settings - Fork 1
97 lines (84 loc) · 2.9 KB
/
container_apps_chat_cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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
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: Deploy pushed image to Azure Container Apps
uses: azure/container-apps-deploy-action@v1
with:
containerAppName: chat
resourceGroup: Jordnaer
imageToDeploy: ghcr.io/nielspilgaard/chat:${{ github.sha }}