Skip to content

Commit d7f19e2

Browse files
committed
Add CI/CD, Docker support, and deployment configs
1 parent 9ac6307 commit d7f19e2

5 files changed

Lines changed: 248 additions & 0 deletions

File tree

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "nuget"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
open-pull-requests-limit: 5

.github/workflows/build.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# =============================================================================
2+
# Author: Vladyslav Zaiets | https://sarmkadan.com
3+
# CTO & Software Architect
4+
# =============================================================================
5+
6+
name: Build & Test
7+
8+
on:
9+
push:
10+
branches: [ main, develop ]
11+
pull_request:
12+
branches: [ main, develop ]
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
services:
19+
mssql:
20+
image: mcr.microsoft.com/mssql/server:2022-latest
21+
env:
22+
SA_PASSWORD: TestPassword123!
23+
ACCEPT_EULA: Y
24+
options: >-
25+
--health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P TestPassword123! -Q 'SELECT 1'"
26+
--health-interval 15s
27+
--health-timeout 5s
28+
--health-retries 5
29+
ports:
30+
- 1433:1433
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Setup .NET
38+
uses: actions/setup-dotnet@v4
39+
with:
40+
dotnet-version: '10.0.x'
41+
42+
- name: Restore dependencies
43+
run: dotnet restore
44+
45+
- name: Build
46+
run: dotnet build --configuration Release --no-restore
47+
48+
- name: Run tests
49+
run: dotnet test --configuration Release --no-build --logger "console;verbosity=detailed"
50+
env:
51+
ConnectionStrings__DefaultConnection: "Server=localhost;Database=FeatureFlagEngineTest;User Id=sa;Password=TestPassword123!;TrustServerCertificate=true;"
52+
53+
- name: Pack NuGet
54+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
55+
run: dotnet pack src/FeatureFlags/FeatureFlags.csproj --configuration Release --output ./nupkg
56+
57+
- name: Upload NuGet artifacts
58+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: nuget-package
62+
path: ./nupkg/**/*.nupkg
63+
64+
code-quality:
65+
runs-on: ubuntu-latest
66+
67+
steps:
68+
- uses: actions/checkout@v4
69+
with:
70+
fetch-depth: 0
71+
72+
- name: Setup .NET
73+
uses: actions/setup-dotnet@v4
74+
with:
75+
dotnet-version: '10.0.x'
76+
77+
- name: Restore dependencies
78+
run: dotnet restore
79+
80+
- name: Analyze code style
81+
run: dotnet format --verify-no-changes --verbosity diagnostic
82+
83+
- name: SonarCloud Scan
84+
uses: SonarSource/sonarcloud-github-action@master
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
88+
89+
security:
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- uses: actions/checkout@v4
94+
95+
- name: Run Trivy vulnerability scanner
96+
uses: aquasecurity/trivy-action@master
97+
with:
98+
scan-type: 'fs'
99+
scan-ref: '.'
100+
format: 'sarif'
101+
output: 'trivy-results.sarif'
102+
103+
- name: Upload Trivy results to GitHub Security tab
104+
uses: github/codeql-action/upload-sarif@v3
105+
with:
106+
sarif_file: 'trivy-results.sarif'
107+
108+
docker-build:
109+
runs-on: ubuntu-latest
110+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
111+
112+
steps:
113+
- uses: actions/checkout@v4
114+
115+
- name: Set up Docker Buildx
116+
uses: docker/setup-buildx-action@v3
117+
118+
- name: Build Docker image
119+
uses: docker/build-push-action@v5
120+
with:
121+
context: .
122+
push: false
123+
tags: feature-flags:${{ github.sha }}
124+
cache-from: type=registry,ref=feature-flags:buildcache
125+
cache-to: type=registry,ref=feature-flags:buildcache,mode=max

.github/workflows/codeql.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '0 6 * * 1'
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
strategy:
20+
matrix:
21+
language: [ 'csharp' ]
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
- name: Initialize CodeQL
26+
uses: github/codeql-action/init@v3
27+
with:
28+
languages: ${{ matrix.language }}
29+
- name: Build
30+
uses: github/codeql-action/autobuild@v3
31+
- name: Perform Analysis
32+
uses: github/codeql-action/analyze@v3
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: NuGet Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-dotnet@v4
13+
with:
14+
dotnet-version: '10.0.x'
15+
- run: dotnet pack -c Release
16+
- run: dotnet nuget push **/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate

docker-compose.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# =============================================================================
2+
# Author: Vladyslav Zaiets | https://sarmkadan.com
3+
# CTO & Software Architect
4+
# =============================================================================
5+
6+
version: '3.8'
7+
8+
services:
9+
mssql:
10+
image: mcr.microsoft.com/mssql/server:2022-latest
11+
container_name: featureflags-mssql
12+
environment:
13+
SA_PASSWORD: "YourStrongPassword123!"
14+
ACCEPT_EULA: "Y"
15+
ports:
16+
- "1433:1433"
17+
volumes:
18+
- mssql-data:/var/opt/mssql
19+
healthcheck:
20+
test: ["CMD-SHELL", "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P YourStrongPassword123! -Q 'SELECT 1' || exit 1"]
21+
interval: 15s
22+
timeout: 5s
23+
retries: 5
24+
start_period: 10s
25+
networks:
26+
- featureflags-network
27+
28+
api:
29+
build:
30+
context: .
31+
dockerfile: Dockerfile
32+
container_name: featureflags-api
33+
depends_on:
34+
mssql:
35+
condition: service_healthy
36+
environment:
37+
ASPNETCORE_ENVIRONMENT: Production
38+
ASPNETCORE_URLS: http://+:80
39+
ConnectionStrings__DefaultConnection: >
40+
Server=mssql;Database=FeatureFlagEngine;User Id=sa;Password=YourStrongPassword123!;TrustServerCertificate=true;
41+
FeatureFlags__EnableCache: "true"
42+
FeatureFlags__CacheDurationMinutes: "5"
43+
FeatureFlags__AuditLogRetentionDays: "365"
44+
FeatureFlags__EnableAuditLogging: "true"
45+
ports:
46+
- "5000:80"
47+
healthcheck:
48+
test: ["CMD", "curl", "-f", "http://localhost/health"]
49+
interval: 30s
50+
timeout: 3s
51+
retries: 3
52+
start_period: 30s
53+
networks:
54+
- featureflags-network
55+
volumes:
56+
- ./logs:/app/logs
57+
58+
volumes:
59+
mssql-data:
60+
61+
networks:
62+
featureflags-network:
63+
driver: bridge

0 commit comments

Comments
 (0)