Skip to content

Commit

Permalink
avoid multiple workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
akostadinov committed Nov 9, 2023
1 parent a5402f7 commit e2aff46
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 35 deletions.
32 changes: 23 additions & 9 deletions .github/workflows/container-image-buildah.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
name: Container Image Reusable Workflow

on:
workflow_call:
workflow_dispatch:
inputs:
platforms:
description: comma-separated list of platforms to build for, e.g. linux/amd64,linux/s390x,linux/ppc64le
platforms: &platforms
description: "comma-separated list of platforms to build for, downstream supported are linux/amd64,linux/s390x,linux/ppc64le; note: clang is broken on s390x (RHEL-15874), also cross-builds take more than 6 hours so we don't do them"
default: linux/amd64
type: string
custom_tag:
description: optional custom tag on remote repo you want image to be tagged with
description: &tag optional custom tag on remote repo you want image to be tagged with
default: scratch
workflow_call:
inputs:
platforms: *platforms
custom_tag:
description: *tag
required: false
default: ''
type: string
schedule:
# every Wednesday morning
- cron: 7 7 * * 3
push:
branches: [ main ]
tags: [ "**" ]
pull_request:
types: [opened, reopened, synchronize]

concurrency:
group: ci-container-build-${{ github.ref }}-1
Expand Down Expand Up @@ -65,7 +78,7 @@ jobs:
uses: redhat-actions/buildah-build@v2
with:
tags: ${{ steps.meta.outputs.tags }}
platforms: ${{ inputs.platforms }}
platforms: ${{ inputs.platforms == '' && 'linux/amd64' || inputs.platforms }}
labels: ${{ steps.meta.outputs.labels }}
layers: false
oci: true
Expand Down Expand Up @@ -93,18 +106,19 @@ jobs:
# accessing a mapped port from a container did not work so lets
# create a pod where both - server and client have same localhost
podman pod create > podid
platforms=${{ steps.build-image.inputs.platforms }}
test_tag () {
podman run -d --pod-id-file=podid --name=searchd -u 14:0 ${{ steps.build-image.outputs.image-with-tag }}$1
podman run -d --pod-id-file=podid --name=searchd -u 14:0 $platforms$1
sleep 3
podman logs searchd
podman run --pod-id-file=podid --rm --entrypoint "/bin/env" mysql:8 -- mysql -h 127.0.0.1 -P 9306 -e "SELECT * FROM account limit 1;"
podman rm -f searchd
}
if [ $( sed -E -e 's#[^/]##g' <<< ${{ inputs.platforms }} ) != "/" ]; then
if [ $( sed -E -e 's#[^/]##g' <<< $platforms ) != "/" ]; then
# if we are here, user has selected more than one build platform
arch_tags=$( tr ',' ' ' <<< ${{ inputs.platforms }} | tr -d '/' )
arch_tags=$( tr ',' ' ' <<< $platforms | tr -d '/' )
# removed slashes to produce "linuxamd64 linuxs390x linuxppc64le"
for tag in $arch_tags; do test_tag -$tag; done
else
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/container-image.yml

This file was deleted.

0 comments on commit e2aff46

Please sign in to comment.