-
Notifications
You must be signed in to change notification settings - Fork 8
65 lines (54 loc) · 2.11 KB
/
PR-Build-And-Test.yml
File metadata and controls
65 lines (54 loc) · 2.11 KB
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
name: PR Build and Test EssentialCSharp.Web
on:
pull_request:
branches: ["main"]
workflow_dispatch:
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up .NET Core
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json
- name: Set up dependency caching for faster builds
uses: actions/cache@v5
id: nuget-cache
with:
path: |
~/.nuget/packages
${{ github.workspace }}/**/obj/project.assets.json
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
${{ runner.os }}-nuget-
- name: Restore with dotnet
run: dotnet restore /p:AccessToNugetFeed=false
- name: Build with dotnet
run: dotnet build --configuration Release --no-restore /p:AccessToNugetFeed=false
- name: Expose GitHub Actions Runtime
uses: actions/github-script@v9
with:
script: |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN']);
core.exportVariable('ACTIONS_RESULTS_URL', process.env['ACTIONS_RESULTS_URL']);
- name: Run .NET Tests
run: dotnet test --no-build --configuration Release --report-trx --coverage --results-directory ${{ runner.temp }}
- name: Convert TRX to VS Playlist
if: failure()
uses: BenjaminMichaelis/trx-to-vsplaylist@v3
with:
trx-file-path: '${{ runner.temp }}/*.trx'
output-directory: '${{ runner.temp }}/vsplaylists'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build Container Image
uses: docker/build-push-action@v7
with:
file: ./EssentialCSharp.Web/Dockerfile
context: .
outputs: type=docker,dest=${{ github.workspace }}/essentialcsharpwebimage.tar
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: ACCESS_TO_NUGET_FEED=false