Skip to content

Commit 54ce0e8

Browse files
authored
ci: Add reusable image build workflow (#1057)
* chore: Remove invalid action input * ci: Add reusable image build workflow * ci(airflow): Migrate build workflow to reusable workflow * ci: Bump actions in reusable workflow * ci: Migrate all products/tools to reusable workflow
1 parent 6b017cb commit 54ce0e8

26 files changed

+392
-3225
lines changed

Diff for: .github/workflows/build_airflow.yaml

+10-129
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name: Build Airflow
33
run-name: |
44
Build Airflow (attempt #${{ github.run_attempt }})
55
6-
env:
7-
PRODUCT_NAME: airflow
8-
SDP_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || '0.0.0-dev' }}
9-
106
on:
117
workflow_dispatch:
128
schedule:
@@ -22,130 +18,15 @@ on:
2218
- stackable-base/**
2319
- .github/actions/**
2420
- .github/workflows/build_airflow.yaml
21+
- .github/workflows/reusable_build_image.yaml
2522

2623
jobs:
27-
generate_matrix:
28-
name: Generate Version List
29-
runs-on: ubuntu-latest
30-
steps:
31-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
32-
with:
33-
persist-credentials: false
34-
- id: shard
35-
uses: stackabletech/actions/shard@320eae677555385b3d40e1c3a81d9263b72742e4 # 0.6.0
36-
with:
37-
product-name: ${{ env.PRODUCT_NAME }}
38-
outputs:
39-
versions: ${{ steps.shard.outputs.versions }}
40-
41-
build:
42-
name: Build/Publish ${{ matrix.versions }}-${{ matrix.runner.arch }} Image
43-
needs: [generate_matrix]
44-
permissions:
45-
id-token: write
46-
runs-on: ${{ matrix.runner.name }}
47-
strategy:
48-
fail-fast: false
49-
matrix:
50-
runner:
51-
- {name: "ubuntu-latest", arch: "amd64"}
52-
- {name: "ubicloud-standard-8-arm", arch: "arm64"}
53-
versions: ${{ fromJson(needs.generate_matrix.outputs.versions) }}
54-
steps:
55-
- name: Checkout Repository
56-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
57-
with:
58-
persist-credentials: false
59-
60-
- name: Free Disk Space
61-
uses: stackabletech/actions/free-disk-space@320eae677555385b3d40e1c3a81d9263b72742e4 # 0.6.0
62-
63-
- name: Build Product Image
64-
id: build
65-
uses: stackabletech/actions/build-product-image@320eae677555385b3d40e1c3a81d9263b72742e4 # 0.6.0
66-
with:
67-
product-name: ${{ env.PRODUCT_NAME }}
68-
product-version: ${{ matrix.versions }}
69-
build-cache-password: ${{ secrets.BUILD_CACHE_NEXUS_PASSWORD }}
70-
sdp-version: ${{ env.SDP_VERSION }}
71-
72-
- name: Publish Container Image on oci.stackable.tech
73-
uses: stackabletech/actions/publish-image@320eae677555385b3d40e1c3a81d9263b72742e4 # 0.6.0
74-
with:
75-
image-registry-uri: oci.stackable.tech
76-
image-registry-username: robot$sdp+github-action-build
77-
image-registry-password: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
78-
image-repository: sdp/${{ env.PRODUCT_NAME }}
79-
image-manifest-tag: ${{ steps.build.outputs.image-manifest-tag }}
80-
source-image-uri: localhost/${{ env.PRODUCT_NAME }}:${{ steps.build.outputs.image-manifest-tag }}
81-
82-
publish_manifests:
83-
name: Build/Publish ${{ matrix.versions }} Manifests
84-
needs: [generate_matrix, build]
85-
permissions:
86-
id-token: write
87-
runs-on: ubuntu-latest
88-
strategy:
89-
fail-fast: false
90-
matrix:
91-
versions: ${{ fromJson(needs.generate_matrix.outputs.versions) }}
92-
steps:
93-
- name: Checkout Repository
94-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
95-
with:
96-
persist-credentials: false
97-
98-
- name: Publish and Sign Image Index Manifest to oci.stackable.tech
99-
uses: stackabletech/actions/publish-index-manifest@320eae677555385b3d40e1c3a81d9263b72742e4 # 0.6.0
100-
with:
101-
image-registry-uri: oci.stackable.tech
102-
image-registry-username: robot$sdp+github-action-build
103-
image-registry-password: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
104-
image-repository: sdp/${{ env.PRODUCT_NAME }}
105-
image-index-manifest-tag: ${{ matrix.versions }}-stackable${{ env.SDP_VERSION }}
106-
107-
notify:
108-
name: Failure Notification
109-
needs: [generate_matrix, build, publish_manifests]
110-
runs-on: ubuntu-latest
111-
if: failure()
112-
steps:
113-
- uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
114-
with:
115-
channel-id: "C07UG6JH44F" # notifications-container-images
116-
payload: |
117-
{
118-
"text": "*${{ github.workflow }}* failed (attempt ${{ github.run_attempt }})",
119-
"attachments": [
120-
{
121-
"pretext": "See the details below for a summary of which job(s) failed.",
122-
"color": "#aa0000",
123-
"fields": [
124-
{
125-
"title": "Generate Version List",
126-
"short": true,
127-
"value": "${{ needs.generate_matrix.result }}"
128-
},
129-
{
130-
"title": "Build/Publish Image",
131-
"short": true,
132-
"value": "${{ needs.build.result }}"
133-
},
134-
{
135-
"title": "Build/Publish Manifests",
136-
"short": true,
137-
"value": "${{ needs.publish_manifests.result }}"
138-
}
139-
],
140-
"actions": [
141-
{
142-
"type": "button",
143-
"text": "Go to workflow run",
144-
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}"
145-
}
146-
]
147-
}
148-
]
149-
}
150-
env:
151-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_CONTAINER_IMAGE_TOKEN }}
24+
build_image:
25+
name: Reusable Workflow
26+
uses: ./.github/workflows/reusable_build_image.yaml
27+
secrets:
28+
harbor-robot-secret: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
29+
slack-token: ${{ secrets.SLACK_CONTAINER_IMAGE_TOKEN }}
30+
with:
31+
product-name: airflow
32+
sdp-version: ${{ github.ref_type == 'tag' && github.ref_name || '0.0.0-dev' }}

Diff for: .github/workflows/build_druid.yaml

+10-129
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name: Build Druid
33
run-name: |
44
Build Druid (attempt #${{ github.run_attempt }})
55
6-
env:
7-
PRODUCT_NAME: druid
8-
SDP_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || '0.0.0-dev' }}
9-
106
on:
117
workflow_dispatch:
128
schedule:
@@ -24,130 +20,15 @@ on:
2420
- java-devel/**
2521
- .github/actions/**
2622
- .github/workflows/build_druid.yaml
23+
- .github/workflows/reusable_build_image.yaml
2724

2825
jobs:
29-
generate_matrix:
30-
name: Generate Version List
31-
runs-on: ubuntu-latest
32-
steps:
33-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
34-
with:
35-
persist-credentials: false
36-
- id: shard
37-
uses: stackabletech/actions/shard@320eae677555385b3d40e1c3a81d9263b72742e4 # 0.6.0
38-
with:
39-
product-name: ${{ env.PRODUCT_NAME }}
40-
outputs:
41-
versions: ${{ steps.shard.outputs.versions }}
42-
43-
build:
44-
name: Build/Publish ${{ matrix.versions }}-${{ matrix.runner.arch }} Image
45-
needs: [generate_matrix]
46-
permissions:
47-
id-token: write
48-
runs-on: ${{ matrix.runner.name }}
49-
strategy:
50-
fail-fast: false
51-
matrix:
52-
runner:
53-
- {name: "ubuntu-latest", arch: "amd64"}
54-
- {name: "ubicloud-standard-8-arm", arch: "arm64"}
55-
versions: ${{ fromJson(needs.generate_matrix.outputs.versions) }}
56-
steps:
57-
- name: Checkout Repository
58-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
59-
with:
60-
persist-credentials: false
61-
62-
- name: Free Disk Space
63-
uses: stackabletech/actions/free-disk-space@320eae677555385b3d40e1c3a81d9263b72742e4 # 0.6.0
64-
65-
- name: Build Product Image
66-
id: build
67-
uses: stackabletech/actions/build-product-image@320eae677555385b3d40e1c3a81d9263b72742e4 # 0.6.0
68-
with:
69-
product-name: ${{ env.PRODUCT_NAME }}
70-
product-version: ${{ matrix.versions }}
71-
build-cache-password: ${{ secrets.BUILD_CACHE_NEXUS_PASSWORD }}
72-
sdp-version: ${{ env.SDP_VERSION }}
73-
74-
- name: Publish Container Image on oci.stackable.tech
75-
uses: stackabletech/actions/publish-image@320eae677555385b3d40e1c3a81d9263b72742e4 # 0.6.0
76-
with:
77-
image-registry-uri: oci.stackable.tech
78-
image-registry-username: robot$sdp+github-action-build
79-
image-registry-password: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
80-
image-repository: sdp/${{ env.PRODUCT_NAME }}
81-
image-manifest-tag: ${{ steps.build.outputs.image-manifest-tag }}
82-
source-image-uri: localhost/${{ env.PRODUCT_NAME }}:${{ steps.build.outputs.image-manifest-tag }}
83-
84-
publish_manifests:
85-
name: Build/Publish ${{ matrix.versions }} Manifests
86-
needs: [generate_matrix, build]
87-
permissions:
88-
id-token: write
89-
runs-on: ubuntu-latest
90-
strategy:
91-
fail-fast: false
92-
matrix:
93-
versions: ${{ fromJson(needs.generate_matrix.outputs.versions) }}
94-
steps:
95-
- name: Checkout Repository
96-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
97-
with:
98-
persist-credentials: false
99-
100-
- name: Publish and Sign Image Index Manifest to oci.stackable.tech
101-
uses: stackabletech/actions/publish-index-manifest@320eae677555385b3d40e1c3a81d9263b72742e4 # 0.6.0
102-
with:
103-
image-registry-uri: oci.stackable.tech
104-
image-registry-username: robot$sdp+github-action-build
105-
image-registry-password: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
106-
image-repository: sdp/${{ env.PRODUCT_NAME }}
107-
image-index-manifest-tag: ${{ matrix.versions }}-stackable${{ env.SDP_VERSION }}
108-
109-
notify:
110-
name: Failure Notification
111-
needs: [generate_matrix, build, publish_manifests]
112-
runs-on: ubuntu-latest
113-
if: failure()
114-
steps:
115-
- uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
116-
with:
117-
channel-id: "C07UG6JH44F" # notifications-container-images
118-
payload: |
119-
{
120-
"text": "*${{ github.workflow }}* failed (attempt ${{ github.run_attempt }})",
121-
"attachments": [
122-
{
123-
"pretext": "See the details below for a summary of which job(s) failed.",
124-
"color": "#aa0000",
125-
"fields": [
126-
{
127-
"title": "Generate Version List",
128-
"short": true,
129-
"value": "${{ needs.generate_matrix.result }}"
130-
},
131-
{
132-
"title": "Build/Publish Image",
133-
"short": true,
134-
"value": "${{ needs.build.result }}"
135-
},
136-
{
137-
"title": "Build/Publish Manifests",
138-
"short": true,
139-
"value": "${{ needs.publish_manifests.result }}"
140-
}
141-
],
142-
"actions": [
143-
{
144-
"type": "button",
145-
"text": "Go to workflow run",
146-
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}"
147-
}
148-
]
149-
}
150-
]
151-
}
152-
env:
153-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_CONTAINER_IMAGE_TOKEN }}
26+
build_image:
27+
name: Reusable Workflow
28+
uses: ./.github/workflows/reusable_build_image.yaml
29+
secrets:
30+
harbor-robot-secret: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
31+
slack-token: ${{ secrets.SLACK_CONTAINER_IMAGE_TOKEN }}
32+
with:
33+
product-name: druid
34+
sdp-version: ${{ github.ref_type == 'tag' && github.ref_name || '0.0.0-dev' }}

0 commit comments

Comments
 (0)