forked from Sofie-Automation/sofie-core
-
Notifications
You must be signed in to change notification settings - Fork 1
254 lines (211 loc) · 7.46 KB
/
Copy pathrelease-docker.yml
File metadata and controls
254 lines (211 loc) · 7.46 KB
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
name: Release with Docker image to GHCR
on:
workflow_dispatch:
push:
branches:
- main
tags:
- "v**"
permissions:
contents: read
jobs:
verify:
name: Verify release should continue
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
continue: ${{ steps.verify_branch.outputs.continue }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Verify ref points to a commit on main branch
id: verify_branch
run: |
REF_COMMIT=$(git rev-list -n 1 "$GITHUB_REF")
echo "Ref commit: $REF_COMMIT"
git fetch origin main
MAIN_COMMIT=$(git rev-parse origin/main)
echo "Main commit: $MAIN_COMMIT"
if git merge-base --is-ancestor "$REF_COMMIT" "$MAIN_COMMIT"; then
echo "continue=true" >> "$GITHUB_OUTPUT"
else
echo "continue=false" >> "$GITHUB_OUTPUT"
fi
- name: Stop if ref is not on main branch
if: steps.verify_branch.outputs.continue != 'true'
run: |
echo "Ref commit is not on main branch, skipping release."
exit 0
build-server-core:
name: Build and push server-core
runs-on: ubuntu-latest
timeout-minutes: 30
needs: verify
if: needs.verify.outputs.continue == 'true'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version-file: ".node-version"
- uses: ./.github/actions/setup-meteor
- name: Prepare Environment
run: |
corepack enable
yarn install
yarn meteor lint
- name: Build libs
run: yarn build:packages
- name: Build webui
run: |
cd packages/webui
yarn build
- name: Persist Built Version information
run: |
cd meteor
yarn inject-git-hash
- name: Prepare webui for meteor build
run: |
rm -Rf meteor/public
cp -R packages/webui/dist meteor/public
- name: Meteor Build
run: |
cd meteor
NODE_OPTIONS="--max-old-space-size=4096" METEOR_DEBUG_BUILD=1 meteor build --allow-superuser --directory .
mv bundle/programs/web.browser/assets/ bundle/programs/web.browser/app/assets/ || true
- name: Meteor Bundle NPM Build
run: |
cd meteor/bundle/programs/server
meteor npm install
- name: Lowercase repository name for GHCR
run: echo "REPO=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Get the Docker tag for GHCR
id: ghcr-tag
uses: docker/metadata-action@v6
with:
images: |
ghcr.io/${{ env.REPO }}-server-core
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=build-${{ github.run_number }},enable=${{ github.ref == 'refs/heads/main' }}
type=ref,event=tag
- name: Note main build tags
if: github.ref == 'refs/heads/main'
run: |
echo "**Main build published**" >> "$GITHUB_STEP_SUMMARY"
echo "- \`ghcr.io/${{ env.REPO }}-server-core:latest\`" >> "$GITHUB_STEP_SUMMARY"
echo "- \`ghcr.io/${{ env.REPO }}-server-core:build-${{ github.run_number }}\`" >> "$GITHUB_STEP_SUMMARY"
- name: Log in to GitHub Container Registry
if: steps.ghcr-tag.outputs.tags != ''
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image to GHCR
if: steps.ghcr-tag.outputs.tags != ''
uses: docker/build-push-action@v7
with:
context: .
file: ./meteor/Dockerfile.circle
push: true
provenance: false
labels: ${{ steps.ghcr-tag.outputs.labels }}
tags: ${{ steps.ghcr-tag.outputs.tags }}
github-token: ${{ github.token }}
build-gateways:
name: Build and push ${{ matrix.gateway-name }}
runs-on: ubuntu-latest
timeout-minutes: 30
needs: verify
if: needs.verify.outputs.continue == 'true'
strategy:
fail-fast: false
matrix:
gateway-name: [playout-gateway, mos-gateway, live-status-gateway]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version-file: ".node-version"
- name: Build
run: |
corepack enable
cd packages
yarn install
yarn build:single ${{ matrix.gateway-name }}/tsconfig.build.json
yarn run pinst --disable
yarn workspaces focus ${{ matrix.gateway-name }} --production
- name: Lowercase repository name for GHCR
run: echo "REPO=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Get the Docker tag for GHCR
id: ghcr-tag
uses: docker/metadata-action@v6
with:
images: |
ghcr.io/${{ env.REPO }}-${{ matrix.gateway-name }}
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=build-${{ github.run_number }},enable=${{ github.ref == 'refs/heads/main' }}
type=ref,event=tag
- name: Log in to GitHub Container Registry
if: steps.ghcr-tag.outputs.tags != ''
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image to GHCR
if: steps.ghcr-tag.outputs.tags != ''
uses: docker/build-push-action@v7
with:
context: ./packages
file: ./packages/${{ matrix.gateway-name }}/Dockerfile.circle
push: true
provenance: false
labels: ${{ steps.ghcr-tag.outputs.labels }}
tags: ${{ steps.ghcr-tag.outputs.tags }}
github-token: ${{ github.token }}
release:
name: Create GitHub Release
runs-on: ubuntu-latest
timeout-minutes: 5
needs:
- verify
- build-server-core
- build-gateways
if: needs.verify.outputs.continue == 'true' && startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Lowercase repository name for GHCR
run: echo "REPO=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: |
Docker images pushed to GHCR:
```bash
docker pull ghcr.io/${{ env.REPO }}-server-core:${{ github.ref_name }}
docker pull ghcr.io/${{ env.REPO }}-playout-gateway:${{ github.ref_name }}
docker pull ghcr.io/${{ env.REPO }}-mos-gateway:${{ github.ref_name }}
docker pull ghcr.io/${{ env.REPO }}-live-status-gateway:${{ github.ref_name }}
```
`latest` continues to track the most recent `main` build.