Skip to content

Commit d927e1f

Browse files
authored
Refactor CI/CD workflow for builds and deployments
1 parent b0aa78e commit d927e1f

File tree

1 file changed

+68
-27
lines changed

1 file changed

+68
-27
lines changed

.github/workflows/dotnet-build.yml

Lines changed: 68 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,73 @@ 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
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:
44+
name: 🚀 Deploy to Dev
45+
runs-on: ubuntu-latest
46+
if: github.ref == 'refs/heads/develop'
47+
environment:
48+
name: deploytodev
49+
needs: [build]
50+
51+
steps:
52+
- name: Download artifact from build job
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: ship-services-app
56+
path: .
57+
58+
- name: deploy step
59+
run: |
60+
echo "deployment to Dev"
61+
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)