Repository navigation
235 lines (218 loc) · 8.66 KB
/
Copy pathbuild.yaml
File metadata and controls
235 lines (218 loc) · 8.66 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
---
name: Build Cockpit Container Image
permissions:
contents: read
on:
push:
branches:
- main
tags:
- '[0-9].[0-9]+.[0-9]+'
- '[0-9].[0-9]+.[0-9]+-rc[0-9]+'
schedule:
# Run every Saturday morning: https://crontab.guru/#15_3_*_*_6
- cron: '15 3 * * 6'
pull_request:
# Do not limit by paths. This workflow contains a required job.
merge_group:
env:
IMAGE_NAME: 'cockpit'
jobs:
detect-changes:
name: Detect relevant changed files
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
fetch-depth: 0
- name: Check for changed files
id: check
uses: stackabletech/actions/detect-changes@e8aed001d347bcf693e41b61f4098b0cb94b4ab6 # v0.18.0
with:
patterns: |
- '.github/workflows/build.yaml'
- '.dockerignore'
- 'docker/**'
- 'messages/**'
- 'package*.json'
- '.npmrc'
- '.node-version'
- 'project.inlang/**'
- 'src/**'
- 'static/**'
- 'svelte.config.js'
- 'tsconfig.json'
- 'vite.config.ts'
- '!e2e/**'
- 'deploy/**'
outputs:
detected: ${{ steps.check.outputs.detected }}
build-container-image:
name: Build/Publish ${{ matrix.runner.arch }} Image
if: (github.event_name != 'merge_group') && needs.detect-changes.outputs.detected == 'true'
needs: [detect-changes]
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
runner:
- { name: 'ubuntu-latest', arch: 'amd64' }
- { name: 'ubicloud-standard-8-arm', arch: 'arm64' }
runs-on: ${{ matrix.runner.name }}
outputs:
image-version: ${{ steps.version.outputs.IMAGE_VERSION }}
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Determine Image Version
id: version
env:
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_DEBUG: ${{ runner.debug }}
GITHUB_REF_TYPE: ${{ github.ref_type }}
GITHUB_REF_NAME: ${{ github.ref_name }}
shell: bash
run: |
set -euo pipefail
[ -n "$GITHUB_DEBUG" ] && set -x
if [ "$GITHUB_EVENT_NAME" == 'pull_request' ]; then
# Include a PR suffix if this workflow is triggered by a PR
if [ "$PR_BASE_REF" == 'main' ]; then
IMAGE_VERSION="0.0.0-pr$PR_NUMBER"
else
# For PRs against non-main branches, use a version based on package.json
CURRENT_VERSION=$(node -p "require('./package.json').version")
IMAGE_VERSION="$CURRENT_VERSION-pr$PR_NUMBER"
fi
elif [ "$GITHUB_REF_TYPE" == 'tag' ]; then
# Use the tag name as the version
IMAGE_VERSION="$GITHUB_REF_NAME"
else
# Default to 0.0.0-dev for other events
IMAGE_VERSION="0.0.0-dev"
fi
echo "IMAGE_VERSION=$IMAGE_VERSION" | tee -a "$GITHUB_OUTPUT"
- name: Build Container Image
id: build
uses: stackabletech/actions/build-container-image@e8aed001d347bcf693e41b61f4098b0cb94b4ab6 # v0.18.0
with:
image-name: ${{ env.IMAGE_NAME }}
image-index-manifest-tag: ${{ steps.version.outputs.IMAGE_VERSION }}
build-arguments: |
VERSION=${{ steps.version.outputs.IMAGE_VERSION }}
TARGETARCH=${{ matrix.runner.arch }}
container-file: docker/Dockerfile
# Dependabot PRs have no access to repository secrets, so they build the image without publishing it.
- name: Publish Container Image
if: github.event.pull_request.user.login != 'dependabot[bot]'
uses: stackabletech/actions/publish-image@e8aed001d347bcf693e41b61f4098b0cb94b4ab6 # v0.18.0
with:
image-registry-uri: oci.stackable.tech
image-registry-username: robot$sdp+github-action-build
image-registry-password: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
image-repository: sdp/${{ env.IMAGE_NAME }}
canonical-image-manifest-tag: ${{ steps.build.outputs.image-manifest-tag }}
canonical-source-image-uri: ${{ steps.build.outputs.image-manifest-uri }}
publish-index-manifest:
name: Publish/Sign ${{ needs.build-container-image.outputs.image-version }} Index
if: (github.event_name != 'merge_group') && needs.detect-changes.outputs.detected == 'true' && github.event.pull_request.user.login != 'dependabot[bot]'
needs:
- detect-changes
- build-container-image
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Publish and Sign Image Index
uses: stackabletech/actions/publish-image-index-manifest@e8aed001d347bcf693e41b61f4098b0cb94b4ab6 # v0.18.0
with:
image-registry-uri: oci.stackable.tech
image-registry-username: robot$sdp+github-action-build
image-registry-password: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
image-repository: sdp/${{ env.IMAGE_NAME }}
canonical-image-index-manifest-tag: ${{ needs.build-container-image.outputs.image-version }}
publish-helm-chart:
name: Package/Publish ${{ needs.build-container-image.outputs.image-version }} Helm Chart
if: (github.event_name != 'merge_group') && needs.detect-changes.outputs.detected == 'true'
needs:
- detect-changes
- build-container-image
- publish-index-manifest
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
persist-credentials: false
- name: Package, Publish, and Sign Helm Chart
uses: stackabletech/actions/publish-helm-chart@e8aed001d347bcf693e41b61f4098b0cb94b4ab6 # v0.18.0
with:
chart-registry-uri: oci.stackable.tech
chart-registry-username: robot$sdp-charts+github-action-build
chart-registry-password: ${{ secrets.HARBOR_ROBOT_SDP_CHARTS_GITHUB_ACTION_BUILD_SECRET }}
chart-repository: sdp-charts
chart-directory: deploy/helm/${{ env.IMAGE_NAME }}
chart-version: ${{ needs.build-container-image.outputs.image-version }}
app-version: ${{ needs.build-container-image.outputs.image-version }}
openshift-preflight-check:
name: Run OpenShift Preflight Check for ${{ needs.build-container-image.outputs.image-version }}-${{ matrix.arch }}
if: (github.event_name != 'merge_group') && needs.detect-changes.outputs.detected == 'true'
needs:
- detect-changes
- build-container-image
- publish-index-manifest
strategy:
fail-fast: false
matrix:
arch:
- amd64
- arm64
runs-on: ubuntu-latest
steps:
- name: Run OpenShift Preflight Check
uses: stackabletech/actions/run-openshift-preflight@e8aed001d347bcf693e41b61f4098b0cb94b4ab6 # v0.18.0
with:
image-index-uri: oci.stackable.tech/sdp/${{ env.IMAGE_NAME }}:${{ needs.build-container-image.outputs.image-version }}
image-architecture: ${{ matrix.arch }}
# This job is a required check in GitHub Settings for this repository.
finished:
# WARNING: Do not change the name unless you will also be changing the
# Required Checks (in branch protections) in GitHub settings.
name: Finished Build and Publish
if: always()
needs:
- openshift-preflight-check
- detect-changes
- build-container-image
- publish-index-manifest
- publish-helm-chart
runs-on: ubuntu-latest
steps:
- name: Check results
env:
NEEDS_RESULTS: ${{ toJSON(needs.*.result) }}
run: |
set -euo pipefail
echo "$NEEDS_RESULTS"
if jq -e 'any(. == "failure" or . == "cancelled")' <<<"$NEEDS_RESULTS" >/dev/null; then
echo "One or more required jobs failed or were cancelled"
exit 1
fi
echo "All required jobs passed or were skipped"