-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (92 loc) · 2.67 KB
/
Build-deploy-code-docker.yml
File metadata and controls
114 lines (92 loc) · 2.67 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Docker & .NET App CI/CD
on:
workflow_dispatch:
env:
EXPECTED_RESPONSE: "Hello World!"
AZURE_WEBAPP_PACKAGE_PATH: ./publish
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Run tests
run: dotnet test
build-docker:
runs-on: ubuntu-latest
needs: [build, test]
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to registry
uses: docker/login-action@v2
with:
registry: https://index.docker.io/v1/
username: ${{ secrets.AzureAppService_ContainerUsername_007dc16c00194a579ee0e182f3912414 }}
password: ${{ secrets.AzureAppService_ContainerPassword_03b591a7c15d426aa4439cb5a79e30b8 }}
- name: Build and push container image to registry
uses: docker/build-push-action@v3
with:
push: true
tags: forsanta/webapi-starter-dotnet8:${{ github.sha }}
file: ./Dockerfile
build-binary:
needs: [build, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Publish app
run: dotnet publish -c Release -o publish
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: dotnet-publish
path: publish/
deploy-binary:
permissions:
contents: none
runs-on: ubuntu-latest
needs: build-binary
environment:
name: 'Development'
outputs:
webapp-url: ${{ steps.set-url.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: dotnet-publish
path: ./publish
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: app-as-code
publish-profi