Skip to content

Commit 6533a71

Browse files
authored
Merge pull request #1 from retailcoder/add-github-actions
Add GitHub actions
2 parents 0d5df87 + a6bd7f1 commit 6533a71

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

.github/workflows/dotnet-cd.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Deploy to Azure VM
2+
3+
env:
4+
DOTNET_VERSION: '8'
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
build:
16+
runs-on: windows-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up .NET Core
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: ${{ env.DOTNET_VERSION }}
25+
26+
- name: Set up dependency caching for faster builds
27+
uses: actions/cache@v3
28+
with:
29+
path: ~/.nuget/packages
30+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
31+
restore-keys: |
32+
${{ runner.os }}-nuget-
33+
34+
- name: Build with dotnet
35+
run: dotnet build --configuration Release
36+
37+
- name: dotnet publish
38+
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/pub
39+
40+
- name: Upload artifact for deployment job
41+
uses: actions/upload-artifact@v3
42+
with:
43+
name: .net-app
44+
path: ${{env.DOTNET_ROOT}}/pub
45+
46+
deploy:
47+
permissions:
48+
contents: none
49+
runs-on: windows-latest
50+
needs: build
51+
steps:
52+
- name: Download artifact from build job
53+
uses: actions/download-artifact@v3
54+
with:
55+
name: .net-app
56+
- name: Deploy to IIS
57+
id: deploy-to-iis
58+
uses: ChristopheLav/iis-deploy@v1
59+
with:
60+
website-name: 'api'
61+
msdeploy-service-url: ${{ secrets.MSDEPLOY_URL }}
62+
msdeploy-username: ${{ secrets.MSDEPLOY_USERNAME }}
63+
msdeploy-password: ${{ secrets.MSDEPLOY_PASSWORD }}
64+
source-path: ${{ github.workspace }}\website\publish

.github/workflows/dotnet-ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: dotnet-CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Setup .NET
15+
uses: actions/setup-dotnet@v4
16+
with:
17+
dotnet-version: 8.0.x
18+
- name: Restore dependencies
19+
run: dotnet restore
20+
- name: Build
21+
run: dotnet build --no-restore
22+
- name: Test
23+
run: dotnet test --no-build --verbosity normal
24+

0 commit comments

Comments
 (0)