-
Notifications
You must be signed in to change notification settings - Fork 1
228 lines (225 loc) · 8.36 KB
/
scala.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
name: Scala CI
on:
push:
branches:
- master
- release/*
- dev/*
- cluster/*
tags:
- '*'
pull_request:
branches:
- master
- release/*
- dev/*
- cluster/*
workflow_dispatch:
jobs:
tarsrc:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: generate routes
run: ./py-build-routes.py 10
- name: tar all
run: tar -zcf src.tar app conf lib project public sbt-dist script seed test build.sbt sbt sbt.bat sbt-debug
- name: save tar
uses: actions/upload-artifact@v3
with:
name: src.tar
path: src.tar
imagedev:
runs-on: ubuntu-20.04
if: github.event_name != 'pull_request'
needs: tarsrc
steps:
- uses: actions/checkout@v3
- name: Fetch artifact
uses: actions/download-artifact@v3
with:
name: src.tar
- name: set docker env (branch non PR)
if: github.ref_type == 'branch' && github.event_name != 'pull_request'
shell: bash
run: |
echo "REF_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / _)" >> $GITHUB_ENV
echo "ECR_REPO=cbidb-api-dev-snapshot" >> $GITHUB_ENV
- name: set docker env (branch PR)
if: github.ref_type == 'branch' && github.event_name == 'pull_request'
shell: bash
run: |
echo "REF_NAME=$(echo ${GITHUB_HEAD_REF} | tr / _)" >> $GITHUB_ENV
echo "ECR_REPO=cbidb-api-dev-snapshot" >> $GITHUB_ENV
- name: set docker env (tag)
if: github.ref_type == 'tag'
shell: bash
run: |
echo "REF_NAME=$(echo ${GITHUB_REF#refs/tags/} | tr / _ | sed 's/^v//g')" >> $GITHUB_ENV
echo "ECR_REPO=cbidb-api-dev-release" >> $GITHUB_ENV
- name: echo vars
run: |
echo ${{ env.REF_NAME }}
echo ${{ env.ECR_REPO }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_ID }}
aws-secret-access-key: ${{ secrets.AWS_ACCESS_TOKEN }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: build image
run: docker build -t ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPO }}:${{ env.REF_NAME }} -f Dockerfile.build .
- name: tag & push aws
run: docker push ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPO }}:${{ env.REF_NAME }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
buildpub:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: generate routes
run: ./py-build-routes.py 1
- name: write git hash
run: sed -i 's/\$\$GITHUB_SHA\$\$/'"${GITHUB_SHA}"'/' app/org/sailcbi/APIServer/Server/CBIBootLoaderLive.scala
- name: build deb
run: sbt debian:packageBin
- name: rename deb
run: mv target/CBI-DB-API_0.1.0_all.deb target/CBI-DB-API_0.1.0_all-pub.deb
- name: save deb
uses: actions/upload-artifact@v3
with:
name: CBI-DB-API_0.1.0_all-pub.deb
path: target/CBI-DB-API_0.1.0_all-pub.deb
imagepub:
runs-on: ubuntu-20.04
needs: buildpub
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Fetch artifact
uses: actions/download-artifact@v3
with:
name: CBI-DB-API_0.1.0_all-pub.deb
- name: rename image
run: mv CBI-DB-API_0.1.0_all-pub.deb CBI-DB-API_0.1.0_all.deb
- name: set docker env (branch non PR)
if: github.ref_type == 'branch' && github.event_name != 'pull_request'
shell: bash
run: |
echo "REF_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / _)" >> $GITHUB_ENV
echo "ECR_REPO=cbidb-api-pub-snapshot" >> $GITHUB_ENV
- name: set docker env (branch PR)
if: github.ref_type == 'branch' && github.event_name == 'pull_request'
shell: bash
run: |
echo "REF_NAME=$(echo ${GITHUB_HEAD_REF} | tr / _)" >> $GITHUB_ENV
echo "ECR_REPO=cbidb-api-pub-snapshot" >> $GITHUB_ENV
- name: set docker env (tag)
if: github.ref_type == 'tag'
shell: bash
run: |
echo "REF_NAME=$(echo ${GITHUB_REF#refs/tags/} | tr / _ | sed 's/^v//g')" >> $GITHUB_ENV
echo "ECR_REPO=cbidb-api-pub-release" >> $GITHUB_ENV
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_ID }}
aws-secret-access-key: ${{ secrets.AWS_ACCESS_TOKEN }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: echo vars
run: |
echo ${{ env.REF_NAME }}
echo ${{ env.ECR_REPO }}
- name: build image
run: docker build -t ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPO }}:${{ env.REF_NAME }} .
- name: tag & push aws
run: docker push ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPO }}:${{ env.REF_NAME }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
buildstaff:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: generate routes
run: ./py-build-routes.py 10
- name: write git hash
run: sed -i 's/\$\$GITHUB_SHA\$\$/'"${GITHUB_SHA}"'/' app/org/sailcbi/APIServer/Server/CBIBootLoaderLive.scala
- name: build deb
run: sbt debian:packageBin
- name: rename deb
run: mv target/CBI-DB-API_0.1.0_all.deb target/CBI-DB-API_0.1.0_all-staff.deb
- name: save artifact
uses: actions/upload-artifact@v3
with:
name: CBI-DB-API_0.1.0_all-staff.deb
path: target/CBI-DB-API_0.1.0_all-staff.deb
imagestaff:
runs-on: ubuntu-20.04
needs: buildstaff
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Fetch artifact
uses: actions/download-artifact@v3
with:
name: CBI-DB-API_0.1.0_all-staff.deb
- name: rename image
run: mv CBI-DB-API_0.1.0_all-staff.deb CBI-DB-API_0.1.0_all.deb
- name: set docker env (branch non PR)
if: github.ref_type == 'branch' && github.event_name != 'pull_request'
shell: bash
run: |
echo "REF_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / _)" >> $GITHUB_ENV
echo "ECR_REPO=cbidb-api-staff-snapshot" >> $GITHUB_ENV
- name: set docker env (branch PR)
if: github.ref_type == 'branch' && github.event_name == 'pull_request'
shell: bash
run: |
echo "REF_NAME=$(echo ${GITHUB_HEAD_REF} | tr / _)" >> $GITHUB_ENV
echo "ECR_REPO=cbidb-api-staff-snapshot" >> $GITHUB_ENV
- name: set docker env (tag)
if: github.ref_type == 'tag'
shell: bash
run: |
echo "REF_NAME=$(echo ${GITHUB_REF#refs/tags/} | tr / _ | sed 's/^v//g')" >> $GITHUB_ENV
echo "ECR_REPO=cbidb-api-staff-release" >> $GITHUB_ENV
- name: echo vars
run: |
echo ${{ env.REF_NAME }}
echo ${{ env.ECR_REPO }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_ID }}
aws-secret-access-key: ${{ secrets.AWS_ACCESS_TOKEN }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: build image
run: docker build -t ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPO }}:${{ env.REF_NAME }} .
- name: tag & push aws
run: docker push ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPO }}:${{ env.REF_NAME }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}