-
Notifications
You must be signed in to change notification settings - Fork 427
56 lines (48 loc) · 1.65 KB
/
main.yml
File metadata and controls
56 lines (48 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: CI Pipeline
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
jobs:
ci_pipeline:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
# Install Java (Required for Sonar Scanner)
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
# SonarQube Scan (Self-Hosted)
- name: SonarQube Scan
run: |
curl -o sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
unzip sonar-scanner.zip
export PATH=$PATH:$(pwd)/sonar-scanner-5.0.1.3006-linux/bin
sonar-scanner \
-Dsonar.projectKey=your-project-key \
-Dsonar.sources=. \
-Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
-Dsonar.login=${{ secrets.SONAR_TOKEN }}
# Log in to Docker Hub
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
# Build and Push Docker Image
- name: Build and Push Docker Image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/your-app:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/your-app:latest
# Trivy Security Scan
- name: Scan Docker Image with Trivy
uses: aquasecurity/trivy-action@master
with:
image-ref: "${{ secrets.DOCKER_USERNAME }}/your-app:latest"
format: "table"
exit-code: 1
severity: "CRITICAL,HIGH"