-
Notifications
You must be signed in to change notification settings - Fork 2
114 lines (103 loc) · 2.93 KB
/
ci.cd.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
109
110
111
112
113
114
name: Java CI/CD Pipeline with Maven
on:
push:
branches: [ "main", "staging" ]
pull_request:
branches: [ "main", "staging" ]
jobs:
# 1. Build Stage
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn clean install
# 2. Test Stage
test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Run Unit Tests
run: mvn test
- name: Run Integration Tests
run: mvn verify
# 3. Code Quality Check with SonarQube
# quality-check:
# runs-on: ubuntu-latest
# needs: build
# steps:
# - uses: actions/checkout@v4
#
# - name: Set up JDK 17
# uses: actions/setup-java@v4
# with:
# java-version: '17'
# distribution: 'temurin'
#
# - name: SonarQube Scan
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# run: mvn sonar:sonar -Dsonar.login=${{ secrets.SONAR_TOKEN }}
# 4. Deployment Stage
# deploy:
# runs-on: ubuntu-latest
# needs: test
# steps:
# - uses: actions/checkout@v4
#
# - name: Set up JDK 17
# uses: actions/setup-java@v4
# with:
# java-version: '17'
# distribution: 'temurin'
#
# - name: Login to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
#
# - name: Build Docker Image
# run: docker build -t ${{ secrets.DOCKER_USERNAME }}/online-banking-service:${{ github.sha }} .
#
# - name: Push Docker Image
# run: docker push ${{ secrets.DOCKER_USERNAME }}/online-banking-service:${{ github.sha }}
#
# - name: Deploy to Staging
# if: github.ref == 'refs/heads/staging'
# run: |
# echo "Deploying to staging environment"
# # Add deployment script or command here
#
# - name: Deploy to Production
# if: github.ref == 'refs/heads/main'
# run: |
# echo "Deploying to production environment"
# # Add deployment script or command here
# 5. Notifications
# notifications:
# runs-on: ubuntu-latest
# needs: [build, quality-check, test, deploy]
# steps:
# - name: Notify on Success or Failure
# if: always()
# run: |
# if [ "${{ job.status }}" == "success" ]; then
# echo "Build and deployment successful."
# else
# echo "Build or deployment failed."
# fi