Skip to content

Commit b5688fb

Browse files
committed
Add github action for building image
1 parent 1dff530 commit b5688fb

2 files changed

Lines changed: 121 additions & 0 deletions

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Build zync oci container image
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
platforms:
7+
description: comma-separated list of platforms to build for, e.g. linux/amd64,linux/s390x,linux/ppc64le
8+
default: linux/amd64
9+
type: string
10+
custom_tag:
11+
description: optional custom tag on remote repo you want image to be tagged with
12+
required: false
13+
default: ''
14+
type: string
15+
secrets:
16+
QUAY_USER_NAME:
17+
required: false
18+
QUAY_PASSWORD:
19+
required: false
20+
21+
env:
22+
# Use docker.io for Docker Hub if empty
23+
REGISTRY: quay.io
24+
# github.repository as <account>/<repo>
25+
IMAGE_NAME: ${{ github.repository }}
26+
27+
jobs:
28+
buildah:
29+
runs-on: ubuntu-latest
30+
steps:
31+
# Allow multi-target builds
32+
# - name: Set up QEMU
33+
# uses: docker/setup-qemu-action@v2
34+
# with:
35+
# platforms: ${{ inputs.platforms }}
36+
37+
- name: Log in to Red Hat Registry
38+
uses: redhat-actions/podman-login@v1
39+
with:
40+
registry: ${{ env.REGISTRY }}
41+
username: ${{ secrets.QUAY_USER_NAME }}
42+
password: ${{ secrets.QUAY_PASSWORD }}
43+
44+
- name: Docker meta
45+
id: meta
46+
uses: docker/metadata-action@v5
47+
with:
48+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
49+
tags: |
50+
type=schedule
51+
type=ref,event=branch,enable=${{ github.ref_name != 'master' && inputs.custom_tag == '' }}
52+
type=raw,value=latest,enable=${{ github.ref_name == 'master' }}
53+
type=raw,value=nightly,enable=${{ github.ref_name == 'master' }}
54+
${{ inputs.custom_tag }}
55+
type=ref,event=tag
56+
type=ref,event=pr
57+
58+
- uses: actions/checkout@v6
59+
60+
- name: Build image
61+
id: build-image
62+
uses: redhat-actions/buildah-build@v2
63+
with:
64+
tags: ${{ steps.meta.outputs.tags }}
65+
# enable platforms once base image has them
66+
# platforms: ${{ inputs.platforms }}
67+
labels: ${{ steps.meta.outputs.labels }}
68+
layers: false
69+
oci: true
70+
tls-verify: true
71+
extra-args: |
72+
--squash
73+
containerfiles: |
74+
Dockerfile
75+
76+
- name: Echo Outputs
77+
run: |
78+
echo "Image: ${{ steps.build-image.outputs.image }}"
79+
echo "Tags: ${{ steps.build-image.outputs.tags }}"
80+
echo "Tagged Image: ${{ steps.build-image.outputs.image-with-tag }}"
81+
82+
- name: Check images created
83+
run: buildah images
84+
85+
- name: Push To quay.io
86+
id: push-to-quay
87+
uses: redhat-actions/push-to-registry@v2
88+
if: github.event_name != 'pull_request'
89+
with:
90+
tags: ${{ steps.build-image.outputs.tags }}
91+
92+
- name: Print image url
93+
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"

.github/workflows/container.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Container build
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- managed-services
7+
- 3scale-[0-9]+.[0-9]+-stable
8+
- add-image-build-action
9+
tags:
10+
- 3scale-[0-9]+.[0-9]+.[0-9]+-GA
11+
workflow_dispatch:
12+
inputs:
13+
platforms:
14+
description: comma-separated list of platforms to build for, downstream supported are linux/amd64,linux/s390x,linux/ppc64le
15+
default: linux/amd64
16+
custom_tag:
17+
description: a custom tag on remote repo you want image to be tagged with
18+
default: scratch
19+
20+
jobs:
21+
call-build:
22+
uses: ./.github/workflows/container-image-buildah.yml
23+
with:
24+
platforms: ${{ inputs.platforms }}
25+
custom_tag: ${{ inputs.custom_tag }}
26+
secrets: # inherit doesn't work for some reason
27+
QUAY_USER_NAME: ${{ secrets.QUAY_USER_NAME }}
28+
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}

0 commit comments

Comments
 (0)