From e2aff465c792f400afd5eb2bea4b5deeb5bef279 Mon Sep 17 00:00:00 2001 From: "Aleksandar N. Kostadinov" Date: Thu, 9 Nov 2023 15:09:08 +0200 Subject: [PATCH] avoid multiple workflows --- .github/workflows/container-image-buildah.yml | 32 +++++++++++++------ .github/workflows/container-image.yml | 26 --------------- 2 files changed, 23 insertions(+), 35 deletions(-) delete mode 100644 .github/workflows/container-image.yml diff --git a/.github/workflows/container-image-buildah.yml b/.github/workflows/container-image-buildah.yml index 879f2f3..043e71b 100644 --- a/.github/workflows/container-image-buildah.yml +++ b/.github/workflows/container-image-buildah.yml @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/container-image.yml b/.github/workflows/container-image.yml deleted file mode 100644 index efd9047..0000000 --- a/.github/workflows/container-image.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Container Image - -on: - schedule: - # every Wednesday morning - - cron: 7 7 * * 3 - push: - branches: [ main ] - tags: [ ** ] - pull_request: - types: [opened, reopened, synchronize] - 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: a custom tag on remote repo you want image to be tagged with - default: scratch - -jobs: - call-build: - uses: ./.github/workflows/container-image-buildah.yml - with: - platforms: ${{ inputs.platforms == '' && 'linux/amd64' || inputs.platforms }} - custom_tag: ${{ inputs.custom_tag }}