Skip to content

Commit eb8d215

Browse files
update workflows to build and publish ubi images
1 parent 08a774a commit eb8d215

File tree

3 files changed

+83
-3
lines changed

3 files changed

+83
-3
lines changed

.github/workflows/pull_request.yaml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
env:
99
DOCKER_FILE_PATH: Dockerfile
10+
UBI_DOCKER_FILE_PATH: Dockerfile.ubi
1011
KUBERNETES_VERSION: "1.19.0"
1112
KIND_VERSION: "0.17.0"
1213
REGISTRY: ghcr.io
@@ -82,12 +83,14 @@ jobs:
8283
- name: Test
8384
run: make test
8485

85-
- name: Generate Tag
86+
- name: Generate Tags
8687
id: generate_tag
8788
run: |
8889
sha=${{ github.event.pull_request.head.sha }}
8990
tag="SNAPSHOT-PR-${{ github.event.pull_request.number }}-${sha:0:8}"
91+
ubi_tag="SNAPSHOT-PR-${{ github.event.pull_request.number }}-UBI-${sha:0:8}"
9092
echo "GIT_TAG=$(echo ${tag})" >> $GITHUB_OUTPUT
93+
echo "GIT_UBI_TAG=$(echo ${ubi_tag})" >> $GITHUB_OUTPUT
9194
9295
- name: Set up QEMU
9396
uses: docker/setup-qemu-action@v2
@@ -122,6 +125,25 @@ jobs:
122125
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
123126
org.opencontainers.image.revision=${{ github.sha }}
124127
128+
- name: Build and Push Docker UBI Image to Docker registry
129+
uses: docker/build-push-action@v4
130+
with:
131+
context: .
132+
file: ${{ env.DOCKER_UBI_FILE_PATH }}
133+
pull: true
134+
push: true
135+
build-args: |
136+
BUILD_PARAMETERS=${{ env.BUILD_PARAMETERS }}
137+
BUILDER_IMAGE=${{ env.DOCKER_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }}
138+
cache-to: type=inline
139+
platforms: linux/amd64,linux/arm,linux/arm64
140+
tags: |
141+
${{ env.DOCKER_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_UBI_TAG }}
142+
labels: |
143+
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
144+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
145+
org.opencontainers.image.revision=${{ github.sha }}
146+
125147
- name: Login to ghcr registry
126148
uses: docker/login-action@v2
127149
with:
@@ -150,13 +172,32 @@ jobs:
150172
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
151173
org.opencontainers.image.revision=${{ github.sha }}
152174
175+
- name: Build and Push Docker UBI Image to ghcr registry
176+
uses: docker/build-push-action@v4
177+
with:
178+
context: .
179+
file: ${{ env.DOCKER_UBI_FILE_PATH }}
180+
pull: true
181+
push: true
182+
build-args: |
183+
BUILD_PARAMETERS=${{ env.BUILD_PARAMETERS }}
184+
BUILDER_IMAGE=${{ env.DOCKER_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }}
185+
cache-to: type=inline
186+
platforms: linux/amd64,linux/arm,linux/arm64
187+
tags: |
188+
${{ env.GHCR_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_UBI_TAG }}
189+
labels: |
190+
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
191+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
192+
org.opencontainers.image.revision=${{ github.sha }}
193+
153194
- name: Comment on PR
154195
uses: mshick/add-pr-comment@v2
155196
if: always()
156197
env:
157198
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158199
with:
159-
message-success: '@${{ github.actor }} Image is available for testing. `docker pull ${{ env.GHCR_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }}`'
200+
message-success: '@${{ github.actor }} Images are available for testing. `docker pull ${{ env.GHCR_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }}`\n`docker pull ${{ env.GHCR_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_UBI_TAG }}`'
160201
message-failure: '@${{ github.actor }} Yikes! You better fix it before anyone else finds out! [Build](https://github.com/${{ github.repository }}/commit/${{ github.event.pull_request.head.sha }}/checks) has Failed!'
161202
allow-repeats: true
162203

.github/workflows/push.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
env:
99
DOCKER_FILE_PATH: Dockerfile
10+
DOCKER_UBI_FILE_PATH: Dockerfile.ubi
1011
KUBERNETES_VERSION: "1.19.0"
1112
KIND_VERSION: "0.17.0"
1213
HELM_REGISTRY_URL: "https://stakater.github.io/stakater-charts"
@@ -111,6 +112,25 @@ jobs:
111112
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
112113
org.opencontainers.image.revision=${{ github.sha }}
113114
115+
- name: Build and Push Docker UBI Image to Docker registry
116+
uses: docker/build-push-action@v4
117+
with:
118+
context: .
119+
file: ${{ env.DOCKER_UBI_FILE_PATH }}
120+
pull: true
121+
push: true
122+
build-args: |
123+
BUILD_PARAMETERS=${{ env.BUILD_PARAMETERS }}
124+
BUILDER_IMAGE= ${{ env.DOCKER_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.new_tag }}
125+
cache-to: type=inline
126+
platforms: linux/amd64,linux/arm,linux/arm64
127+
tags: |
128+
${{ env.DOCKER_IMAGE_REPOSITORY }}:ubi-${{ steps.generate_tag.outputs.new_tag }}
129+
labels: |
130+
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
131+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
132+
org.opencontainers.image.revision=${{ github.sha }}
133+
114134
- name: Login to ghcr registry
115135
uses: docker/login-action@v2
116136
with:
@@ -139,6 +159,25 @@ jobs:
139159
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
140160
org.opencontainers.image.revision=${{ github.sha }}
141161
162+
- name: Build and Push Docker UBI Image to ghcr registry
163+
uses: docker/build-push-action@v4
164+
with:
165+
context: .
166+
file: ${{ env.DOCKER_FILE_PATH }}
167+
pull: true
168+
push: true
169+
build-args: |
170+
BUILD_PARAMETERS=${{ env.BUILD_PARAMETERS }}
171+
BUILDER_IMAGE= ${{ env.DOCKER_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.new_tag }}
172+
cache-to: type=inline
173+
platforms: linux/amd64,linux/arm,linux/arm64
174+
tags: |
175+
${{ env.GHCR_IMAGE_REPOSITORY }}:ubi-${{ steps.generate_tag.outputs.new_tag }}
176+
labels: |
177+
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
178+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
179+
org.opencontainers.image.revision=${{ github.sha }}
180+
142181
##############################
143182
## Add steps to generate required artifacts for a release here(helm chart, operator manifest etc.)
144183
##############################

Dockerfile.ubi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ARG BUILDER_IMAGE
22
ARG BASE_IMAGE
33

4-
FROM ${BUILDER_IMAGE:-docker.io/stakater/reloader:v1.0.44} as SRC
4+
FROM ${BUILDER_IMAGE} as SRC
55

66
FROM ${BASE_IMAGE:-registry.access.redhat.com/ubi8/ubi-minimal}
77

0 commit comments

Comments
 (0)