forked from ShouraySolanki/knowlg-search
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (83 loc) · 2.56 KB
/
search-api-build.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
name: search api workflow
on:
push:
branches:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 14
distribution: 'adopt'
architecture: x64
- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2
key: kp-dependency-build-cache-${{ hashFiles('pom.xml') }}
- name: Build the project
run: |
cd search-api/
ls
mvn clean install -DskipTests
- name: Login to docker hub
uses: docker/login-action@v2
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build docker image and push
run: |
docker images
cd search-api/
sh knowlg-docker-image.sh ${{ github.ref_name }}
docker images
docker tag search-service:${{ github.ref_name }} ${{ vars.DOCKERHUB_USERNAME }}/search-service:${{ github.ref_name }}
docker push ${{ vars.DOCKERHUB_USERNAME }}/search-service:${{ github.ref_name }}
- name: Store Maven dependencies cache
uses: actions/cache@v2
with:
path: ~/.m2
key: kp-dependency-build-cache-${{ hashFiles('pom.xml') }}
unit-tests:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 14
distribution: 'adopt'
architecture: x64
- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2
key: kp-dependency-test-cache-${{ hashFiles('pom.xml') }}
- name: Setup environment and run tests
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
cd search-api/
bash vmsetup.sh
- name: Save test results
run: |
mkdir -p ~/test-results/junit/
find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/junit/ \;
if: always()
- name: Store Maven dependencies cache
uses: actions/cache@v2
with:
path: ~/.m2
key: kp-dependency-test-cache-${{ hashFiles('pom.xml') }}
- name: Upload test results
uses: actions/upload-artifact@v2
with:
name: test-results
path: ~/test-results