-
Notifications
You must be signed in to change notification settings - Fork 10
84 lines (69 loc) · 2.59 KB
/
build_test_and_publish.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
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET NuGet & Docker Publish
on:
release:
types: [ published ]
jobs:
build:
name: Build, Test & Publish to NuGet
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
env:
BUILD_CONFIG: 'Release'
steps:
- uses: actions/checkout@v3
- name: Extract branch name
shell: bash
run: echo "##[set-output name=value;]$(echo ${GITHUB_REF#refs/tags/v})"
id: branch_name
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_API_USERNAME }}
password: ${{ secrets.DOCKER_API_KEY }}
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Setup NuGet
uses: nuget/setup-nuget@v1
with:
nuget-version: 'latest'
- name: docker compose -f ./docker-compose/docker-compose.tests.yml up -d
run: docker compose -f ./docker-compose/docker-compose.tests.yml up -d
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration $BUILD_CONFIG -p:Version=${{ steps.branch_name.outputs.value }} --no-restore
- name: Test
run: dotnet test --no-build --configuration $BUILD_CONFIG --logger "trx" --verbosity d --results-directory "./"
- name: Upload test results
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: test-results
path: ./*.trx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build & Push Docker image with latest tag
uses: docker/build-push-action@v3
if: ${{ !contains(steps.branch_name.outputs.value, 'pre') }}
with:
context: ./
file: src/OnlineSales/Dockerfile
push: true
tags: wavepoint/onlinesales:latest, wavepoint/onlinesales:${{ steps.branch_name.outputs.value }}
- name: Build & Push Docker image without latest tag
uses: docker/build-push-action@v3
if: ${{ contains(steps.branch_name.outputs.value, 'pre') }}
with:
context: ./
file: src/OnlineSales/Dockerfile
push: true
tags: wavepoint/onlinesales:develop, wavepoint/onlinesales:${{ steps.branch_name.outputs.value }}
- name: Publish to NuGet
if: success()
run: nuget push **\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}}