Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit 024363e

Browse files
authored
Merge pull request #46 from Its4Nik/ci/cd-rework
Feat: Setup CI/CD pipelines
2 parents 3755750 + d95032f commit 024363e

3 files changed

Lines changed: 141 additions & 152 deletions

File tree

.github/workflows/cd.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Continuous Delivery
2+
3+
on:
4+
release:
5+
types: [published, prereleased]
6+
7+
permissions:
8+
contents: read
9+
packages: write
10+
11+
jobs:
12+
publish:
13+
name: Publish Container Image
14+
runs-on: ubuntu-latest
15+
environment: production
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
- name: Login to GHCR
23+
uses: docker/login-action@v3
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Determine tags
30+
id: tags
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: ghcr.io/its4nik/dockstatapi
34+
tags: |
35+
type=semver,pattern={{version}}
36+
type=semver,pattern={{major}}.{{minor}}
37+
type=semver,pattern={{major}}
38+
type=sha
39+
40+
- name: Build and push
41+
uses: docker/build-push-action@v5
42+
with:
43+
context: .
44+
file: docker/Dockerfile
45+
platforms: linux/amd64,linux/arm64
46+
push: true
47+
tags: ${{ steps.tags.outputs.tags }}
48+
49+
sbom:
50+
name: Generate SBOM
51+
runs-on: ubuntu-latest
52+
needs: publish
53+
steps:
54+
- name: Generate SBOM
55+
uses: aquasecurity/trivy-action@0.28.0
56+
with:
57+
image-ref: ghcr.io/its4nik/dockstatapi:${{ github.event.release.tag_name }}
58+
format: spdx-json
59+
output: sbom.json
60+
61+
- name: Upload SBOM
62+
uses: github/codeql-action/upload-sarif@v3
63+
with:
64+
sarif_file: sbom.json

.github/workflows/ci.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
checks: write
12+
security-events: write
13+
14+
jobs:
15+
lint-test:
16+
name: Lint and Test
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Setup Bun
22+
uses: oven-sh/setup-bun@v2
23+
with:
24+
bun-version: latest
25+
26+
- name: Install dependencies
27+
run: bun install
28+
29+
- name: Run linter
30+
run: bun run biome ci
31+
32+
- name: Run unit tests
33+
run: bun test --reporter=junit --reporter-outfile=./unit-test.xml
34+
35+
- name: Publish Test Report
36+
uses: mikepenz/action-junit-report@v5
37+
with:
38+
report_paths: 'unit-test.xml'
39+
40+
build-scan:
41+
name: Build and Security Scan
42+
runs-on: ubuntu-latest
43+
needs: lint-test
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
- name: Build Docker image
51+
uses: docker/build-push-action@v5
52+
with:
53+
context: .
54+
file: docker/Dockerfile
55+
tags: dockstatapi:ci-${{ github.sha }}
56+
load: true
57+
58+
- name: Start and test container
59+
run: |
60+
docker run --name test-container -d dockstatapi:ci-${{ github.sha }}
61+
sleep 10
62+
docker ps | grep test-container
63+
docker logs test-container
64+
docker stop test-container
65+
66+
- name: Trivy vulnerability scan
67+
uses: aquasecurity/trivy-action@0.28.0
68+
with:
69+
image-ref: 'dockstatapi:ci-${{ github.sha }}'
70+
format: 'sarif'
71+
output: 'trivy-results.sarif'
72+
severity: 'HIGH,CRITICAL'
73+
74+
- name: Upload security results
75+
uses: github/codeql-action/upload-sarif@v3
76+
with:
77+
sarif_file: 'trivy-results.sarif'

.github/workflows/pipeline.yaml

Lines changed: 0 additions & 152 deletions
This file was deleted.

0 commit comments

Comments
 (0)