-
Notifications
You must be signed in to change notification settings - Fork 10
193 lines (168 loc) · 6.06 KB
/
release.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
name: XP Release
on:
workflow_call:
inputs:
container_registry:
type: string
required: false
default: ghcr.io
environment:
type: string
required: false
secrets:
ghcr_token:
required: true
env:
ARTIFACT_RETENTION_DAYS: 7
jobs:
build-ui:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ui
steps:
- name: Checkout to the target branch
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: yarn
cache-dependency-path: ui/yarn.lock
- name: Install
run: yarn install --network-concurrency 1
- name: Lint code
run: yarn lint
- name: Build UI
env:
NODE_OPTIONS: "--max_old_space_size=4096"
run: yarn build
- name: Publish Artifact
uses: actions/upload-artifact@v4
with:
name: xp-ui-dist
path: ui/build/
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
build-management-service:
runs-on: ubuntu-latest
env:
APP_NAME: xp-management
needs:
- build-ui
outputs:
api-version: ${{ steps.build-image.outputs.api-version }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download UI Dist
uses: actions/download-artifact@v4
with:
name: xp-ui-dist
path: ui/build
- name: Download Management Service binary
uses: actions/download-artifact@v4
with:
name: management-service-binary
path: management-service/bin/
- name: Build Docker image
id: build-image
run: |
set -o pipefail
make BIN_NAME=$APP_NAME build-image | tee output.log
echo "::set-output name=api-version::$(sed -n 's%xp-api version: \(.*\)%\1%p' output.log)"
- name: Save Docker image
run: |
docker image save \
--output xp-management.${{ steps.build-image.outputs.api-version }}.tar \
xp-management:${{ steps.build-image.outputs.api-version }}
- name: Publish Artifact
uses: actions/upload-artifact@v4
with:
name: xp-management.${{ steps.build-image.outputs.api-version }}.tar
path: xp-management.${{ steps.build-image.outputs.api-version }}.tar
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
build-treatment-service:
runs-on: ubuntu-latest
env:
APP_NAME: xp-treatment
outputs:
api-version: ${{ steps.build-image.outputs.api-version }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download Treatment Service binary
uses: actions/download-artifact@v4
with:
name: treatment-service-binary
path: treatment-service/bin/
- name: Build Docker image
id: build-image
working-directory: treatment-service
run: |
set -o pipefail
make BIN_NAME=$APP_NAME build-image | tee output.log
echo "::set-output name=api-version::$(sed -n 's%xp-api version: \(.*\)%\1%p' output.log)"
- name: Save Docker image
run: |
docker image save \
--output xp-treatment.${{ steps.build-image.outputs.api-version }}.tar \
xp-treatment:${{ steps.build-image.outputs.api-version }}
- name: Publish Artifact
uses: actions/upload-artifact@v4
with:
name: xp-treatment.${{ steps.build-image.outputs.api-version }}.tar
path: xp-treatment.${{ steps.build-image.outputs.api-version }}.tar
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
publish-management-service:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
needs:
- build-management-service
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.container_registry }}
username: ${{ github.actor }}
password: ${{ secrets.ghcr_token }}
- name: Download Docker image tar
uses: actions/download-artifact@v4
with:
name: xp-management.${{ needs.build-management-service.outputs.api-version }}.tar
- name: Publish Docker Image
env:
DOCKER_REPOSITORY: ${{ inputs.container_registry }}/${{ github.repository }}
run: |
docker image load --input xp-management.${{ needs.build-management-service.outputs.api-version }}.tar
docker tag \
xp-management:${{ needs.build-management-service.outputs.api-version }} \
${{ env.DOCKER_REPOSITORY }}/xp-management:${{ needs.build-management-service.outputs.api-version }}
docker push ${{ env.DOCKER_REPOSITORY }}/xp-management:${{ needs.build-management-service.outputs.api-version }}
publish-treatment-service:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
needs:
- build-treatment-service
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.container_registry }}
username: ${{ github.actor }}
password: ${{ secrets.ghcr_token }}
- name: Download Docker image tar
uses: actions/download-artifact@v4
with:
name: xp-treatment.${{ needs.build-treatment-service.outputs.api-version }}.tar
- name: Publish Docker Image
env:
DOCKER_REPOSITORY: ${{ inputs.container_registry }}/${{ github.repository }}
run: |
docker image load --input xp-treatment.${{ needs.build-treatment-service.outputs.api-version }}.tar
docker tag \
xp-treatment:${{ needs.build-treatment-service.outputs.api-version }} \
${{ env.DOCKER_REPOSITORY }}/xp-treatment:${{ needs.build-treatment-service.outputs.api-version }}
docker push ${{ env.DOCKER_REPOSITORY }}/xp-treatment:${{ needs.build-treatment-service.outputs.api-version }}