-
Notifications
You must be signed in to change notification settings - Fork 2
94 lines (80 loc) · 2.29 KB
/
build-and-stage.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
name: Build and stage
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_VERSION: '8.0'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
checks: write
contents: read
statuses: write
jobs:
build:
name: Build and publish app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Set up dependency caching for faster builds
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: dotnet restore
run: dotnet restore
- name: dotnet build
run: dotnet build --no-restore /p:TreatWarningsAsErrors=True
- name: dotnet test
run: dotnet test --logger trx --results-directory "${{ runner.temp }}" --no-build
- name: dotnet test
uses: NasAmin/[email protected]
with:
TRX_PATH: "${{ runner.temp }}"
REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: dotnet publish
run: dotnet publish src/InitializrService/Steeltoe.InitializrService.csproj -o publish
- name: Upload artifact for deployment job
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: published-app
path: publish
deploy:
name: Deploy
environment: production
needs:
- build
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: published-app
- name: Log into Azure CLI with service principal
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: ${{ vars.AZURE_WEBAPP_NAME }}
package: '.'
slot-name: 'production'