-
Notifications
You must be signed in to change notification settings - Fork 3
182 lines (151 loc) · 4.85 KB
/
ci.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
name: CI
on:
workflow_call:
pull_request:
push:
branches:
- main
tags:
- '*'
jobs:
front-build:
runs-on: ubuntu-latest
env:
PORT: 3000
APP_ID: mockingbird
NODE_ENV: production
RELATIVE_PATH: /mockingbird
ASSETS_FOLDER_NAME: /assets
ASSETS_PREFIX: /mockingbird/assets/
MOCKINGBIRD_API: /api/internal/mockingbird
MOCKINGBIRD_EXEC_API: /api/mockingbird/exec
DEBUG_PLAIN: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Build
run: |
cd frontend
rm ./env.development.js
mkdir -p ./dist/out${ASSETS_FOLDER_NAME}
npm install
npm run build
- name: Copy output
run: |
cd frontend
cp -r ./dist/static${RELATIVE_PATH}/. ./dist/out
cp -a ./dist/client/. ./dist/out${ASSETS_FOLDER_NAME}
- name: Upload output directories
uses: actions/upload-artifact@v3
with:
name: front-static
path: frontend/dist/out
back-build:
needs: [front-build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download frontend
uses: actions/download-artifact@v3
with:
name: front-static
path: frontend/dist/out
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
check-latest: true
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: '3.20.0'
- name: Get the Ref
id: get-ref
uses: ankitvgupta/[email protected]
with:
ref: ${{ github.ref }}
head_ref: ${{ github.head_ref }}
- name: Compile and test
run: |
cd backend
sbt "project mockingbird-api;clean;fixCheck;test;missinglinkCheck;Docker / stage;"
- name: ZIP stages files
uses: montudor/action-zip@v1
with:
args: zip -r layers.zip ./backend/mockingbird-api/target/docker/stage
if: ${{ github.ref_type == 'tag' }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }}
- name: Build and push docker image
uses: docker/build-push-action@v3
with:
context: ./backend/mockingbird-api/target/docker/stage
push: true
tags: ghcr.io/leviysoft/mockingbird:${{ steps.get-ref.outputs.tag }}
if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }}
- name: Publish layers
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: layers.zip
asset_name: layers.zip
tag: ${{ github.ref_name }}
if: ${{ github.ref_type == 'tag' }}
back-build-native:
needs: [front-build]
runs-on: ubuntu-20.04
env:
CI: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download frontend
uses: actions/download-artifact@v3
with:
name: front-static
path: frontend/dist/out
- uses: graalvm/setup-graalvm@v1
with:
version: '22.3.1'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: '3.20.0'
- name: Get the Ref
id: get-ref
uses: ankitvgupta/[email protected]
with:
ref: ${{ github.ref }}
head_ref: ${{ github.head_ref }}
- name: Compile and test
run: |
cd backend
sbt "project mockingbird-native;clean;fixCheck;test;GraalVMNativeImage / packageBin;Docker / stage;"
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }}
- name: Build and push docker image
uses: docker/build-push-action@v3
with:
context: ./backend/mockingbird-native/target/docker/stage
push: true
tags: ghcr.io/leviysoft/mockingbird:${{ steps.get-ref.outputs.tag }}-native
if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }}