-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (130 loc) · 4.68 KB
/
gradle.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Java CI with Gradle
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
jobs:
build-test-push-docker-image:
runs-on: ubuntu-latest
services:
frontend:
image: yousoundd/frontend:0.0.1
ports:
- "3000:3000"
security:
image: yousoundd/security-service:0.0.1
ports:
- "8082:8082"
steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: "temurin"
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 14
- name: Gradle Clean
run: |
cd backend/yousound
gradle clean
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
chmod +x gradlew
./gradlew build sonarqube --info
working-directory: backend/yousound
- name: Test YouSound
run: |
cd backend/yousound
gradle test
- name: Install frontend dependencies
run: |
cd frontend/yousound-frontend
yarn
- name: Build and start the frontend application
run: |
cd frontend/yousound-frontend
yarn build
yarn start &
- name: Wait for frontend application to start
run: |
sleep 30s
- name: Build and start the backend application
run: |
cd backend/yousound/security-service
chmod +x gradlew
./gradlew build
java -jar build/libs/security-service-1.0-SNAPSHOT.jar &
- name: Wait for backend application to start
run: |
sleep 30s
- name: Security scan with OWASP ZAP
run: |
docker run --network="host" -t owasp/zap2docker-stable zap-baseline.py -t http://172.17.0.1:3000 -I
- name: docker login
env:
DOCKER_USERNAME: '${{ secrets.DOCKER_USERNAME }}'
DOCKER_PASSWORD: '${{ secrets.DOCKER_PASSWORD }}'
run: |
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- name: Build and Push Discovery Server
run: |
cd backend/yousound/discovery-server
docker build -f Dockerfile . -t yousoundd/discovery-server:0.0.1
docker push yousoundd/discovery-server:0.0.1
- name: Build and Push Api Gateway
run: |
cd backend/yousound/api-gateway
docker build -f Dockerfile . -t yousoundd/api-gateway:0.0.1
docker push yousoundd/api-gateway:0.0.1
- name: Build and Push Music Service
run: |
cd backend/yousound/music-service
docker build -f Dockerfile . -t yousoundd/music-service:0.0.1
docker push yousoundd/music-service:0.0.1
- name: Build and Push Security Service
run: |
cd backend/yousound/security-service
docker build -f Dockerfile . -t yousoundd/security-service:0.0.1
docker push yousoundd/security-service:0.0.1
- name: Build and Push Channel Service
run: |
cd backend/yousound/social-service
docker build -f Dockerfile . -t yousoundd/social-service:0.0.1
docker push yousoundd/social-service:0.0.1
- name: Build and Push Channel Service
run: |
cd backend/yousound/user-service
docker build -f Dockerfile . -t yousoundd/user-service:0.0.1
docker push yousoundd/user-service:0.0.1
- name: Build and Push Frontend
run: |
cd frontend/yousound-frontend
docker build -f Dockerfile . -t yousoundd/frontend:0.0.1
docker push yousoundd/frontend:0.0.1