-
Notifications
You must be signed in to change notification settings - Fork 5
212 lines (175 loc) · 6.58 KB
/
build_and_upload_on_push_to_dev.yaml
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
# Deployment workflow is supposed to be dependent on this one.
# 1. At the workflow start four jobs are triggered in parallel (generate version, building all services)
# 2. A job to build Docker image with Saturn service is triggered once version generated and Saturn artifacts
# are built and uploaded
# 3. A job to build Docker image with Pluto service and Mercury bundle is triggered once version generated and
# Pluto/Mercury artifacts are built and uploaded
name: Build & Upload Fairspace Docker images
env:
DOCKER_REGISTRY: ghcr.io
on:
push:
branches:
- dev
- release
jobs:
# A job to generate one shared unique version tag per build cycle for all built artifacts
generate-version:
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.version.outputs.fairspace_version }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- id: version
name: Generating version tag for artifacts
run: |
# EXTRACT VERSION
BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
echo "Building images from the branch: $BRANCH"
VER=$(cat ./VERSION)
echo "Building images of version: $VER"
# DOCKER TAG TO BE ATTACHED (SHARED WITHIN OUTPUT):
VER=$(cat ./VERSION)
if [ $BRANCH != "release" ]
then
VER=$VER-SNAPSHOT
fi
echo "fairspace_version=$VER" >> "$GITHUB_OUTPUT"
echo "Docker tag to be attached to images: $VER"
build-saturn-service:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
- name: Build with Gradle
run: ./projects/saturn/gradlew build -p ./projects/saturn/
- name: Upload generated artifacts for further processing
uses: actions/upload-artifact@v4
with:
name: saturn-build
path: ./projects/saturn/build/distributions/*.tar
build-mercury-fe-bundle:
needs: generate-version
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Set deployment version
env:
VERSION: ${{needs.generate-version.outputs.output1}}
run: |
echo "$VERSION"
sed -i "s/0.0.0-RELEASEVERSION/${{env.VERSION}}/g" projects/mercury/package.json
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install # will run `yarn install`
dir: ./projects/mercury/
- name: Build Mercury bundle
uses: borales/actions-yarn@v4
with:
cmd: build # will run `yarn build`
dir: ./projects/mercury/
# to be used building an image which includes artifacts of both Pluto and Mercury
- name: Upload generated artifacts for further processing
uses: actions/upload-artifact@v4
with:
name: mercury-build
path: ./projects/mercury/build/
- name: Run Mercury tests
uses: borales/actions-yarn@v4
with:
cmd: test # will run `yarn test`
dir: ./projects/mercury/
build-pluto-service:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
- name: Build with Gradle
run: ./projects/pluto/gradlew build -p ./projects/pluto/
# to be used building an image which includes artifacts of both Pluto and Mercury
- name: Upload generated artifacts for further processing
uses: actions/upload-artifact@v4
with:
name: pluto-build
path: ./projects/pluto/build/distributions/*.tar
# Pluto .tar file and Mercury bundle run together in one docker container
build-and-upload-docker-image-with-pluto-and-mercury:
needs: [generate-version, build-mercury-fe-bundle, build-pluto-service]
runs-on: ubuntu-latest
steps:
- name: Check out repository # To get Pluto Dockerfile
uses: actions/checkout@v4
- name: Download Mercury artifacts
uses: actions/download-artifact@v4
with:
name: mercury-build
path: ./projects/pluto/build/mercury
- name: Download Pluto artifacts
uses: actions/download-artifact@v4
with:
name: pluto-build
path: ./projects/pluto/build/distributions/
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/pluto
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./projects/pluto/
push: true
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/pluto:${{needs.generate-version.outputs.output1}}
labels: ${{ steps.meta.outputs.labels }}
build-and-upload-docker-image-for-saturn:
needs: [generate-version, build-saturn-service]
runs-on: ubuntu-latest
steps:
- name: Check out repository # To get Saturn Dockerfile
uses: actions/checkout@v4
- name: Download Saturn artifacts
uses: actions/download-artifact@v4
with:
name: saturn-build
path: ./projects/saturn/build/distributions/
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/saturn
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./projects/saturn/
push: true
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/saturn:${{needs.generate-version.outputs.output1}}
labels: ${{ steps.meta.outputs.labels }}