-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (88 loc) · 3.02 KB
/
CICD.yml
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Java CI with Maven
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- uses: actions/upload-artifact@v4
with:
name: RecipeApp
path: target/*.jar
- name: Print Environment Variables
run: env
- name: Install Trivy
run: |
sudo apt-get update
sudo apt-get install -y wget apt-transport-https gnupg lsb-release
sudo wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
echo "deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install -y trivy
- name: Run Trivy scan
run: |
trivy --version
trivy fs --format table -o trivy-fs-report.html .
# - name: SonarQube Scan
# uses: sonarsource/sonarqube-scan-action@master
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
# - name: Install jq
# run: sudo apt-get update && sudo apt-get install -y jq
# - name: SonarQube Quality Gate check
# id: sonarqube-quality-gate-check
# uses: sonarsource/sonarqube-quality-gate-action@master
# timeout-minutes: 5
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker Image
run: |
docker build -t chaden13/recipeapp:latest .
- name: Trivy Image Scan
run: |
trivy image --format table -o trivy-image-report.html chaden13/recipeapp:latest
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker Image
run: |
docker push chaden13/recipeapp:latest
- name: Kubectl Action
uses: tale/kubectl-action@v1
with:
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
- name: Print Environment Variables
run: |
echo "GitHub Event: $GITHUB_EVENT_NAME"
echo "GitHub Repository: $GITHUB_REPOSITORY"
echo "GitHub Ref: $GITHUB_REF"
echo "GitHub Actor: $GITHUB_ACTOR"
echo "Current Branch: $(git rev-parse --abbrev-ref HEAD)"
echo "Kubeconfig Contents:"
cat $KUBECONFIG
- name: Debug Kubernetes Cluster
run: |
kubectl cluster-info dump
kubectl get pods --all-namespaces
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6