-
-
Notifications
You must be signed in to change notification settings - Fork 6
147 lines (138 loc) · 5.71 KB
/
reusable_build_image.yaml
File metadata and controls
147 lines (138 loc) · 5.71 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
on:
workflow_call:
inputs:
product-name:
required: true
type: string
sdp-version:
required: true
type: string
registry-namespace:
required: true
type: string
runners:
description: |
The type of runners used.
- `mixed`: x86_64 builds run on the GitHub hosted runners and the aarch64 builds run on the Ubicloud runners
- `ubicloud`: Both the x86_64 and the aarch64 builds run on the Ubicloud runners
default: mixed
type: string
secrets:
harbor-robot-secret:
description: The secret for the Harbor robot user used to push images and manifest
required: true
slack-token:
description: The Slack token used to post failure notifications
required: true
jobs:
generate_runner_dimension:
name: Generate Runner Dimension
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- id: runners
shell: bash
env:
RUNNERS_TYPE: ${{ inputs.runners }}
run: |
if [ "$RUNNERS_TYPE" == "mixed" ]; then
RUNNERS=$(jq --compact-output < .github/workflows/runners/mixed.json)
echo "RUNNERS=$RUNNERS" | tee -a "$GITHUB_OUTPUT"
elif [ "$RUNNERS_TYPE" == "ubicloud" ]; then
RUNNERS=$(jq --compact-output < .github/workflows/runners/ubicloud.json)
echo "RUNNERS=$RUNNERS" | tee -a "$GITHUB_OUTPUT"
else
echo "Invalid runners type, expected 'mixed' or 'ubicloud'"
exit 1
fi
outputs:
runners: ${{ steps.runners.outputs.RUNNERS }}
generate_version_dimension:
name: Generate Version Dimension
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- id: shard
uses: stackabletech/actions/shard@7fb064db885e006f6a9eeff69c7cd5ff5dea68bc # v0.13.0
with:
product-name: ${{ inputs.product-name }}
outputs:
versions: ${{ steps.shard.outputs.versions }}
build:
name: Build/Publish ${{ matrix.versions }}-${{ matrix.runner.arch }} Image
needs:
- generate_version_dimension
- generate_runner_dimension
permissions:
id-token: write
runs-on: ${{ matrix.runner.name }}
strategy:
fail-fast: false
matrix:
versions: ${{ fromJson(needs.generate_version_dimension.outputs.versions) }}
runner: ${{ fromJson(needs.generate_runner_dimension.outputs.runners) }}
steps:
- name: Checkout Repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Free Disk Space
uses: stackabletech/actions/free-disk-space@7fb064db885e006f6a9eeff69c7cd5ff5dea68bc # v0.13.0
- name: Build Product Image
id: build
uses: stackabletech/actions/build-product-image@7fb064db885e006f6a9eeff69c7cd5ff5dea68bc # v0.13.0
with:
registry-namespace: ${{ inputs.registry-namespace }}
product-name: ${{ inputs.product-name }}
product-version: ${{ matrix.versions }}
sdp-version: ${{ inputs.sdp-version }}
- name: Publish Container Image on oci.stackable.tech
uses: stackabletech/actions/publish-image@7fb064db885e006f6a9eeff69c7cd5ff5dea68bc # v0.13.0
with:
image-registry-uri: oci.stackable.tech
image-registry-username: robot$${{ inputs.registry-namespace }}+github-action-build
image-registry-password: ${{ secrets.harbor-robot-secret }}
image-repository: ${{ inputs.registry-namespace }}/${{ inputs.product-name }}
image-manifest-tag: ${{ steps.build.outputs.image-manifest-tag }}
source-image-uri: localhost/${{ inputs.registry-namespace }}/${{ inputs.product-name }}:${{ steps.build.outputs.image-manifest-tag }}
publish_manifests:
name: Build/Publish ${{ matrix.versions }} Manifests
needs: [generate_version_dimension, build]
permissions:
id-token: write
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
versions: ${{ fromJson(needs.generate_version_dimension.outputs.versions) }}
steps:
- name: Checkout Repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Publish and Sign Image Index Manifest to oci.stackable.tech
uses: stackabletech/actions/publish-image-index-manifest@7fb064db885e006f6a9eeff69c7cd5ff5dea68bc # v0.13.0
with:
image-registry-uri: oci.stackable.tech
image-registry-username: robot$${{ inputs.registry-namespace }}+github-action-build
image-registry-password: ${{ secrets.harbor-robot-secret }}
image-repository: ${{ inputs.registry-namespace }}/${{ inputs.product-name }}
image-index-manifest-tag: ${{ matrix.versions }}-stackable${{ inputs.sdp-version }}
notify:
name: Failure Notification
needs: [generate_version_dimension, build, publish_manifests]
runs-on: ubuntu-latest
if: failure() || (github.run_attempt > 1 && !cancelled())
steps:
- name: Send Notification
uses: stackabletech/actions/send-slack-notification@7fb064db885e006f6a9eeff69c7cd5ff5dea68bc # v0.13.0
with:
publish-manifests-result: ${{ needs.publish_manifests.result }}
build-result: ${{ needs.build.result }}
slack-token: ${{ secrets.slack-token }}
channel-id: C07UG6JH44F # notifications-container-images
type: container-image-build