Skip to content

Commit

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

on:
workflow_dispatch:
inputs:
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
custom_tag:
description: optional custom tag on remote repo you want image to be tagged with
default: scratch
workflow_call:
inputs:
platforms:
description: comma-separated list of platforms to build for, e.g. linux/amd64,linux/s390x,linux/ppc64le
required: false
default: linux/amd64
type: string
custom_tag:
description: optional custom tag on remote repo you want image to be tagged with
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 All @@ -27,11 +42,18 @@ jobs:
buildah:
runs-on: ubuntu-latest
steps:
- name: Sanitize Platforms
id: platforms
run: |
platforms="${{ inputs.platforms == '' && 'linux/amd64' || inputs.platforms }}"
archs="$( sed -e 's#linux/##g' <<< $platforms )"
echo "platforms=$platforms" >> $GITHUB_OUTPUT
echo "archs=$archs" >> $GITHUB_OUTPUT
# Allow multi-target builds
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: s390x,ppc64le # arm64
platforms: ${{ steps.platforms.outputs.archs }}
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
Expand Down Expand Up @@ -65,7 +87,7 @@ jobs:
uses: redhat-actions/buildah-build@v2
with:
tags: ${{ steps.meta.outputs.tags }}
platforms: ${{ inputs.platforms }}
platforms: ${{ steps.platforms.outputs.platforms }}
labels: ${{ steps.meta.outputs.labels }}
layers: false
oci: true
Expand Down Expand Up @@ -93,18 +115,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.platforms.outputs.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 "${{ steps.build-image.outputs.image-with-tag }}$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 [ x$( sed -E -e 's#[^/]##g' <<< $platforms ) != "x/" ]; 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 2cd7d39

Please sign in to comment.