-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (108 loc) · 3.97 KB
/
dotnet.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: .NET
on:
push:
branches: [ master ]
paths:
- .github/workflows/dotnet.yml
- backend/**
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
packages: write
services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
mysql:
image: mariadb:11.3.2
env:
MYSQL_ROOT_PASSWORD: naheulbook
ports:
- 3306
options: --health-cmd="healthcheck.sh --innodb_initialized" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- name: Set up MySQL
run: |
mysql --port ${{ job.services.mysql.ports['3306'] }} --host 127.0.0.1 -u root --password=naheulbook <<'EOF'
CREATE DATABASE `naheulbook_test` CHARACTER SET UTF8 COLLATE utf8_general_ci;
CREATE USER 'naheulbook_test'@'%' IDENTIFIED BY 'naheulbook';
GRANT ALL PRIVILEGES ON `naheulbook_test`.* TO 'naheulbook_test'@'%';
CREATE DATABASE `naheulbook_integration` CHARACTER SET UTF8 COLLATE utf8_general_ci;
CREATE USER 'naheulbook'@'%' IDENTIFIED BY 'naheulbook';
GRANT ALL PRIVILEGES ON `naheulbook_integration`.* TO 'naheulbook'@'%';
FLUSH PRIVILEGES;
EOF
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
working-directory: backend
- name: Build
run: dotnet build --no-restore -c Release
working-directory: backend
- name: Test
run: dotnet test --no-build --verbosity normal --logger junit -c Release
working-directory: backend
env:
FORCE_COLOR: true
TERM: xterm
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
- name: Publish Unit Test Results
uses: EnricoMi/[email protected]
if: always()
with:
files: "backend/tests/*/TestResults/TestResults.xml"
continue-on-error: true
- name: Publish Naheulbook.Web
run: dotnet publish --no-restore --no-build -c Release ./backend/src/Naheulbook.Web/Naheulbook.Web.csproj
- name: Publish Naheulbook.DatabaseMigrator.Cli
run: dotnet publish --no-restore --no-build -c Release ./backend/tools/Naheulbook.DatabaseMigrator.Cli/Naheulbook.DatabaseMigrator.Cli.csproj
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker - Web
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Extract metadata (tags, labels) for Docker - Db migrator
id: meta-db-migrator
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-db-migrator
- name: Build and push Docker - Web
uses: docker/build-push-action@v3
with:
context: backend/src/Naheulbook.Web/bin/Release/publish/
file: backend/src/Naheulbook.Web/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Docker - Db migrator
uses: docker/build-push-action@v3
with:
context: backend/tools/Naheulbook.DatabaseMigrator.Cli/bin/Release/publish/
file: backend/tools/Naheulbook.DatabaseMigrator.Cli/Dockerfile
push: true
tags: ${{ steps.meta-db-migrator.outputs.tags }}
labels: ${{ steps.meta-db-migrator.outputs.labels }}