-
Notifications
You must be signed in to change notification settings - Fork 1
177 lines (152 loc) · 6.02 KB
/
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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Eperusteet build
on: [workflow_dispatch, push]
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ARTIFACT_NAME: eperusteet
jobs:
build-and-test-eperusteet-service:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: workflow number debug
run: echo "${{ github.run_id }} ${{ github.run_number }} ${{ github.run_attempt }}"
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'corretto'
- name: Cache Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-cache-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: |
cd eperusteet/eperusteet-service
mvn clean verify --batch-mode
- name: Cache eperusteet-service build results
uses: actions/cache@v3
id: restore-service-build
with:
path: eperusteet/eperusteet-service/target
key: ${{ github.run_number }}-${{ github.run_attempt }}-service
build-and-test-eperusteet-ui:
runs-on: ubuntu-latest
env:
EPERUSTEET_SPECFILE: https://raw.githubusercontent.com/Opetushallitus/eperusteet/${{ github.ref_name }}/generated/eperusteet.spec.json
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'corretto'
- name: Set up Node 10
uses: actions/setup-node@v3
with:
node-version: '10'
- name: Cache Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-cache-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Print yarn cache directory path
id: yarn-cache-dir-path
run: |
yarn cache dir
echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Print npm cache directory
id: npm-cache-dir
run: |
npm config get cache
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache npm
uses: actions/cache@v3
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache yo npm
uses: actions/cache@v3
with:
path: eperusteet/eperusteet/eperusteet-app/yo/node_modules
key: ${{ runner.os }}-nodeyo-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-nodeyo-
- name: Check if UI has same branch
id: ui_branch_status
run: |
if [ "$(curl -s -o /dev/null -I -w '%{http_code}' https://github.com/Opetushallitus/eperusteet-ui/tree/${{ github.ref_name }})" == "200" ]
then
echo branch found
echo "EPERUSTEET_UI_GIT_BRANCH=-b ${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "EPERUSTEET_UI_GIT_BRANCH=" >> $GITHUB_ENV
echo branch not found
fi
- name: Build with Maven
run: |
git clone ${{ env.EPERUSTEET_UI_GIT_BRANCH }} --recurse-submodules --depth 1 https://github.com/Opetushallitus/eperusteet-ui.git
export EPERUSTEET_SERVICE_DIR=${{ github.workspace }}/eperusteet/eperusteet-service
cd eperusteet-ui
yarn install --silent
cd eperusteet-frontend-utils/vue
yarn install --silent
yarn gen:api:eperusteet
rm -rf node_modules
cd ../..
echo "----------eperusteet-ui:n viimeisimman commitin sha----------"
git rev-parse HEAD
yarn run build
cp -R dist/ ../eperusteet/eperusteet-app/dist
cd ..
cd ${ARTIFACT_NAME}/eperusteet-app
mvn clean verify --batch-mode
- name: Cache eperusteet-app build results
uses: actions/cache@v3
id: restore-app-build
with:
path: eperusteet/eperusteet-app/target
key: ${{ github.run_number }}-${{ github.run_attempt }}-app
build-image:
needs: [build-and-test-eperusteet-service, build-and-test-eperusteet-ui]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get eperusteet-service build results
uses: actions/cache@v3
id: restore-service-build
with:
path: eperusteet/eperusteet-service/target
key: ${{ github.run_number }}-${{ github.run_attempt }}-service
- name: Get eperusteet-app build results
uses: actions/cache@v3
id: restore-app-build
with:
path: eperusteet/eperusteet-app/target
key: ${{ github.run_number }}-${{ github.run_attempt }}-app
- name: Build image
run: |
git clone https://github.com/Opetushallitus/ci-tools.git
source ci-tools/common/setup-tools.sh
cd ${ARTIFACT_NAME}
mv ${ARTIFACT_NAME}-service/target/${ARTIFACT_NAME}-service.war $DOCKER_BUILD_DIR/artifact/${ARTIFACT_NAME}-service.war
mv ${ARTIFACT_NAME}-app/target/${ARTIFACT_NAME}-app.war $DOCKER_BUILD_DIR/artifact/${ARTIFACT_NAME}-app.war
cp -vr src/main/resources/oph-configuration $DOCKER_BUILD_DIR/config/
cp -vr src/main/resources/tomcat $DOCKER_BUILD_DIR/config/
cd ..
export BASE_IMAGE="baseimage-war-tomcat8-openjdk11:master"
./ci-tools/common/pull-image.sh
./ci-tools/github-build/build-war.sh ${ARTIFACT_NAME}
./ci-tools/github-build/upload-image.sh ${ARTIFACT_NAME}