Skip to content

Commit cd4237f

Browse files
authored
Refactor CI/CD workflow for .NET build and deploy
1 parent a3c6add commit cd4237f

File tree

1 file changed

+50
-29
lines changed

1 file changed

+50
-29
lines changed

.github/workflows/dotnet-build.yml

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,38 @@ on:
99

1010
jobs:
1111
build:
12+
name: 🧪 Build
1213
runs-on: ubuntu-latest
13-
14+
1415
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v4
17-
18-
- name: Setup .NET
19-
uses: actions/setup-dotnet@v4
20-
with:
21-
dotnet-version: '10.0.x'
22-
23-
- name: Restore dependencies
24-
run: dotnet restore ShipServicesApp.sln
25-
26-
- name: Build solution
27-
run: dotnet build ShipServicesApp.sln --configuration Release --no-restore
28-
29-
- name: Run tests
30-
run: dotnet test ShipServicesApp.sln --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage"
31-
32-
- name: Publish application
33-
run: dotnet publish ShipServicesApp.sln --configuration Release --no-build --output ./publish
34-
35-
- name: Upload build artifacts
36-
uses: actions/upload-artifact@v4
37-
with:
38-
name: ship-services-app
39-
path: ./publish
40-
retention-days: 30
41-
42-
deployToDev:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup .NET
20+
uses: actions/setup-dotnet@v4
21+
with:
22+
dotnet-version: '10.0.x'
23+
24+
- name: Restore dependencies
25+
run: dotnet restore ShipServicesApp.sln
26+
27+
- name: Build solution
28+
run: dotnet build ShipServicesApp.sln --configuration Release --no-restore
29+
30+
- name: Run tests
31+
run: dotnet test ShipServicesApp.sln --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage"
32+
33+
- name: Publish application
34+
run: dotnet publish ShipServicesApp.sln --configuration Release --no-build --output ./publish
35+
36+
- name: Upload build artifacts
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: ship-services-app
40+
path: ./publish
41+
retention-days: 30
42+
43+
deployToDev:
4344
name: 🚀 Deploy to Dev
4445
runs-on: ubuntu-latest
4546
# if: github.ref == 'refs/heads/develop'
@@ -58,3 +59,23 @@ jobs:
5859
run: |
5960
echo "deployment to Dev"
6061
ls -la
62+
63+
deployToProd:
64+
name: 🚀 Deploy to Production
65+
runs-on: ubuntu-latest
66+
# if: github.ref == 'refs/heads/main'
67+
environment:
68+
name: deploytoprod
69+
needs: [build, deployToDev]
70+
71+
steps:
72+
- name: Download artifact from build job
73+
uses: actions/download-artifact@v4
74+
with:
75+
name: ship-services-app
76+
path: .
77+
78+
- name: deploy step
79+
run: |
80+
echo "deployment to Prod"
81+
ls -la

0 commit comments

Comments
 (0)