-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
45 lines (45 loc) · 1.23 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
name: dotnet-cicd
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
push_to_docker:
type: boolean
description: Docker Push
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
docker:
name: Docker
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- if: github.event.inputs.push_to_docker == 'true'
name: Build FSH .NET Web API Image
working-directory: ./
run: |
dotnet publish -c Release -p:ContainerImageName=${{ secrets.DOCKER_USERNAME }}/dotnet-webapi -p:RuntimeIdentifier=linux-x64
docker push ${{ secrets.DOCKER_USERNAME }}/dotnet-webapi --all-tags