Skip to content

Merge pull request #489 from jfdenise/main #264

Merge pull request #489 from jfdenise/main

Merge pull request #489 from jfdenise/main #264

Workflow file for this run

name: Build and Deploy images (on push to main or wildfly-cekit-modules's events).
on:
repository_dispatch:
types: [push-in-wf-cekit-modules]
push:
branches:
- "main"
env:
LANG: en_US.UTF-8
V2_QUAY_REPO: ${{ secrets.V2_QUAY_REPO }}
V2_QUAY_SNAPSHOT_REPO: ${{ secrets.V2_QUAY_SNAPSHOT_REPO }}
V2_QUAY_USERNAME: ${{ secrets.V2_QUAY_USERNAME }}
S2I_URI: https://api.github.com/repos/openshift/source-to-image/releases/latest
WILDFLY_S2I_BUILDER_IMAGE: wildfly-s2i
WILDFLY_S2I_RUNTIME_IMAGE: wildfly-runtime
jobs:
wfci:
name: Wildfly-s2i Image Deployment on push
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
jdk: [jdk11, jdk17, jdk21]
steps:
- id: files
if: ${{ github.event_name == 'push' }}
uses: jitterbit/get-changed-files@v1
- run: |
for changed_file in ${{ steps.files.outputs.all }}; do
if [[ "${changed_file}" =~ ^.github/.* ]] || [[ "${changed_file}" =~ ^wildfly-builder-image/.* ]] || [[ "${changed_file}" =~ ^wildfly-runtime-image/.* ]] || [[ "${changed_file}" =~ ^wildfly-modules/.* ]]; then
echo "Change detected in ${changed_file}, will deploy images."
echo "IMPACT_IMAGE=true" >> "$GITHUB_ENV"
exit 0
fi
done
echo "No change detected that would impact the images, skipping the job"
- name: Enable image deployment on dispatched event from wildfly-cekit-modules
if: ${{ github.event_name == 'repository_dispatch' }}
run: |
echo "IMPACT_IMAGE=true" >> "$GITHUB_ENV"
- uses: actions/checkout@v2
if: env.IMPACT_IMAGE == 'true'
with:
ref: main
- name: Check quay.io configuration
if: (env.V2_QUAY_USERNAME == '' || env.V2_QUAY_REPO == '' || env.V2_QUAY_SNAPSHOT_REPO == '') && env.IMPACT_IMAGE == 'true'
run: |
echo "quay.io configuration is incomplete, can't push to quay.io. To push built images to quay.io, please ensure the secrets V2_QUAY_REPO, V2_QUAY_SNAPSHOT_REPO, V2_QUAY_USERNAME and V2_QUAY_PASSWORD are created in the project."
exit 1
- name: Install qemu dependency
if: env.IMPACT_IMAGE == 'true'
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Setup required system packages
if: env.IMPACT_IMAGE == 'true'
run: |
sudo apt-get update
sudo apt-get install krb5-multidev libkrb5-dev
- name: Verify latest ubi9-minimal
if: env.IMPACT_IMAGE == 'true'
run: |
podman pull registry.access.redhat.com/ubi9/ubi-minimal
podman image ls | grep ubi9
- name: Setup virtualenv and install cekit and required packages
if: env.IMPACT_IMAGE == 'true'
run: |
sudo pip install virtualenv
mkdir ~/cekit
virtualenv ~/cekit
. ~/cekit/bin/activate
pip install cekit docker==5.0.3 docker-squash odcs behave lxml packaging==21.3
- name: Build DockerFile files
if: env.IMPACT_IMAGE == 'true'
run: |
echo "Docker Images prior to build wildfly-s2i images"
podman image ls
. ~/cekit/bin/activate
pushd wildfly-builder-image
WILDFLY_IMAGE_VERSION=$(yq e ".version" ${{ matrix.jdk }}-overrides.yaml)
if [[ "${WILDFLY_IMAGE_VERSION}" =~ .*-snapshot ]]; then
ORGANIZATION=${{ secrets.V2_QUAY_SNAPSHOT_REPO }}
QUAY_IMAGE_VERSION=${WILDFLY_IMAGE_VERSION%-snapshot}
else
ORGANIZATION=${{ secrets.V2_QUAY_REPO }}
RELEASED_IMAGES="true"
QUAY_IMAGE_VERSION="${WILDFLY_IMAGE_VERSION}"
fi
# Compute tags common to all images
WILDFLY_IMAGE_TAGS="latest-${{ matrix.jdk }} ${QUAY_IMAGE_VERSION}"
echo "WILDFLY_IMAGE_TAGS=${WILDFLY_IMAGE_TAGS}" >> $GITHUB_ENV
echo "ORGANIZATION=${ORGANIZATION}" >> $GITHUB_ENV
echo "QUAY_IMAGE_VERSION=${QUAY_IMAGE_VERSION}" >> $GITHUB_ENV
cekit build --dry-run --overrides=${{ matrix.jdk }}-overrides.yaml docker
popd
pushd wildfly-runtime-image
cekit build --dry-run --overrides=${{ matrix.jdk }}-overrides.yaml docker
popd
- name: Add latest image tag, currently JDK21
if: env.IMPACT_IMAGE == 'true' && matrix.jdk == 'jdk21'
run: |
echo "WILDFLY_IMAGE_TAGS=latest ${{ env.WILDFLY_IMAGE_TAGS }}" >> $GITHUB_ENV
- name: Buildah multi archs Builder Build
if: env.IMPACT_IMAGE == 'true'
id: build_builder_image
uses: redhat-actions/[email protected]
with:
image: ${{ env.WILDFLY_S2I_BUILDER_IMAGE }}
tags: ${{ env.WILDFLY_IMAGE_TAGS }}
context: ./wildfly-builder-image/target/image
platforms: linux/amd64, linux/arm64, linux/ppc64le
containerfiles: |
./wildfly-builder-image/target/image/Dockerfile
- name: Buildah multi archs Runtime Build
if: env.IMPACT_IMAGE == 'true'
id: build_runtime_image
uses: redhat-actions/[email protected]
with:
image: ${{ env.WILDFLY_S2I_RUNTIME_IMAGE }}
tags: ${{ env.WILDFLY_IMAGE_TAGS }}
context: ./wildfly-runtime-image/target/image
platforms: linux/amd64, linux/arm64, linux/ppc64le
containerfiles: |
./wildfly-runtime-image/target/image/Dockerfile
- name: Push Builder Image To Quay
if: env.IMPACT_IMAGE == 'true'
uses: redhat-actions/[email protected]
id: push-builder
with:
image: ${{ steps.build_builder_image.outputs.image }}
tags: ${{ steps.build_builder_image.outputs.tags }}
registry: quay.io/${{ env.ORGANIZATION }}
username: ${{ secrets.V2_QUAY_USERNAME }}
password: ${{ secrets.V2_QUAY_PASSWORD }}
- name: Push Runtime Image To Quay
if: env.IMPACT_IMAGE == 'true'
uses: redhat-actions/[email protected]
id: push-runtime
with:
image: ${{ steps.build_runtime_image.outputs.image }}
tags: ${{ steps.build_runtime_image.outputs.tags }}
registry: quay.io/${{ env.ORGANIZATION }}
username: ${{ secrets.V2_QUAY_USERNAME }}
password: ${{ secrets.V2_QUAY_PASSWORD }}