-
Notifications
You must be signed in to change notification settings - Fork 86
88 lines (75 loc) · 3.16 KB
/
main.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
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
paths-ignore:
- "README.md"
pull_request:
branches: [main]
paths-ignore:
- "README.md"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: set release date
run: |
echo "BUILD_VERSION=$(date --rfc-3339=date)" >> ${GITHUB_ENV}
- name: Set up .NET Core
uses: actions/[email protected]
with:
dotnet-version: "8.0.x"
dotnet-quality: "preview"
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Install Required Tools
run: |
dotnet new tool-manifest
dotnet tool install dotnet-reportgenerator-globaltool
dotnet tool install dotnet-coverage
- name: Run the unit tests with code coverage
run: dotnet coverage collect dotnet test --filter TodoApiTests --output ${{ github.workspace }}/Tests/Coverage.cobertura.xml --output-format cobertura
- name: Generate Report
run: |
dotnet reportgenerator -reports:${{ github.workspace }}/Tests/Coverage.cobertura.xml -targetdir:"${{ github.workspace }}/Tests/coveragereport" -reporttypes:"MarkdownSummary;Html" -assemblyfilters:+MinimalApi
- name: Upload code coverage report
uses: actions/upload-artifact@v2
with:
name: coveragereport
path: ${{ github.workspace }}/Tests/coveragereport
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: ${{ github.workspace }}/Tests/coveragereport/Summary.md
- name: Configuring Tokens
working-directory: ./Source
run: |
echo "USER1_TOKEN=$(dotnet user-jwts create --claim Username=user1 --claim [email protected] --name user1 --output token)" >> $GITHUB_ENV
echo "USER2_TOKEN=$(dotnet user-jwts create --claim Username=user2 --claim [email protected] --name user2 --output token)" >> $GITHUB_ENV
- name: Running Integration Tests
run: dotnet test --filter TodoApiIntegrationTests
- name: dotnet publish
run: dotnet publish -c Release -o ${{ github.workspace }}/myapp
- name: dotnet publish to Docker
run: dotnet publish --os linux --arch x64 -p:PublishProfile=DefaultContainer
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: .net-app
path: ${{ github.workspace }}/myapp
- name: Login with Github Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Github Container registry
run: docker push ghcr.io/anuraj/minimalapi:${{ env.BUILD_VERSION }}