Skip to content

Update image-build-and-upload.yml #23

Update image-build-and-upload.yml

Update image-build-and-upload.yml #23

name: 🛠️ Build and upload all images
on:
push:
branches:
- "gha-setup"
jobs:
set-constants:
name: 🔠 Setting workflow constants
runs-on: ubuntu-24.04
outputs:
FLAVORS: '[ "f", "r", "s" ]'
VERSIONS: '[ "23.5", "23.6" ]'
RPM_ARCH: '[ "aarch64", "x86_64" ]'
IMAGE_ARCH: '[ "arm64", "amd64" ]'
steps:
- run: echo "setting constants"
download-install-files:
name: ⬇️ Download install binaries
environment: build
runs-on: ubuntu-24.04
needs: set-constants
strategy:
matrix:
versions: ${{ fromJSON(needs.set-constants.outputs.VERSIONS) }}
arch: ${{ fromJSON(needs.set-constants.outputs.RPM_ARCH) }}
steps:
- name: ⬇️ Download install file from web
run: |
mkdir -p ~/.ssh
ssh-keyscan ${{ secrets.FILE_SERVER }} >> ~/.ssh/known_hosts 2>/dev/null
eval $(ssh-agent)
ssh-add - <<< "${{ secrets.FILE_USER_AUTH }}"
scp ${{ secrets.FILE_USER }}@${{ secrets.FILE_SERVER }}:"oracle-database-free-23ai-${{ matrix.versions }}-1.0-1.el8.${{ matrix.arch }}.rpm" .
- name: 💾 Store install file
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: oracle-database-free-23ai-${{ matrix.versions }}-1.0-1.el8.${{ matrix.arch }}.rpm
path: oracle-database-free-23ai-${{ matrix.versions }}-1.0-1.el8.${{ matrix.arch }}.rpm
build-images:
name: 🛠️ 🔬 Build and test images
runs-on: ${{ matrix.os }}
environment: build
needs: [ set-constants, download-install-files ]
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm]
versions: ${{ fromJSON(needs.set-constants.outputs.VERSIONS) }}
flavors: ${{ fromJSON(needs.set-constants.outputs.FLAVORS) }}
steps:
- name: 📂 Checkout repo
uses: actions/checkout@v4
- name: 🔄 Generate environment variables
id: env_vars
run: |
if [ "${{ matrix.flavors }}" == "f" ]; then image_flavor="-full";
elif [ "${{ matrix.flavors }}" == "r" ]; then image_flavor="";
elif [ "${{ matrix.flavors }}" == "s" ]; then image_flavor="-slim";
else image_flavor="";
fi;
echo "IMAGE_FLAVOR=$image_flavor" >> "$GITHUB_OUTPUT"
os_arch=$(uname -m)
if [ "${os_arch}" == "aarch64" ]; then image_arch="arm64";
elif [ "${os_arch}" == "x86_64" ]; then image_arch="amd64";
else image_arch="";
fi;
echo "IMAGE_ARCH=$image_arch" >> "$GITHUB_OUTPUT"
echo "OS_ARCH=$os_arch" >> "$GITHUB_OUTPUT"
- name: ⏬ Install build dependencies
run: sudo apt-get install -y buildah podman
- name: ⬇️ Download stored install file
uses: actions/download-artifact@v4
with:
name: oracle-database-free-23ai-${{ matrix.versions }}-1.0-1.el8.${{ steps.env_vars.outputs.OS_ARCH }}.rpm
- name: 🛠️ Build container image for ${{ matrix.versions }}, flavor "${{ matrix.flavors }}"
run: ./buildContainerImage.sh -v "${{ matrix.versions }}" -${{ matrix.flavors }}
- name: 🛠️ Build faststartcontainer image for ${{ matrix.versions }}, flavor "${{ matrix.flavors }}"
run: ./buildContainerImage.sh -v "${{ matrix.versions }}" -${{ matrix.flavors }} -x
- name: 🔬 Test images
env:
IMAGE_FLAVOR: ${{ steps.env_vars.outputs.IMAGE_FLAVOR }}
IMAGE_ARCH: ${{ steps.env_vars.outputs.IMAGE_ARCH }}
run: |
cd tests
./test-container.sh "gvenzl/oracle-free:${{ matrix.versions }}${IMAGE_FLAVOR}-${IMAGE_ARCH}"
./test-container.sh "gvenzl/oracle-free:${{ matrix.versions }}${IMAGE_FLAVOR}-faststart-${IMAGE_ARCH}"
- name: 📤 Export images to local file system
env:
IMAGE_FLAVOR: ${{ steps.env_vars.outputs.IMAGE_FLAVOR }}
IMAGE_ARCH: ${{ steps.env_vars.outputs.IMAGE_ARCH }}
run: |
podman save -o "oracle-free-${{ matrix.versions }}${IMAGE_FLAVOR}-${IMAGE_ARCH}.tar" "localhost/gvenzl/oracle-free:${{ matrix.versions }}${IMAGE_FLAVOR}-${IMAGE_ARCH}"
podman save -o "oracle-free-${{ matrix.versions }}${IMAGE_FLAVOR}-faststart-${IMAGE_ARCH}.tar" "localhost/gvenzl/oracle-free:${{ matrix.versions }}${IMAGE_FLAVOR}-faststart-${IMAGE_ARCH}"
- name: ⬆️ Upload image non-faststart image for deploy job
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: oracle-free-${{ matrix.versions }}${{ steps.env_vars.outputs.IMAGE_FLAVOR }}-${{ steps.env_vars.outputs.IMAGE_ARCH }}
path: oracle-free-${{ matrix.versions }}${{ steps.env_vars.outputs.IMAGE_FLAVOR }}-${{ steps.env_vars.outputs.IMAGE_ARCH }}.tar
- name: ⬆️ Upload image faststart image for deploy job
uses: actions/upload-artifact@v4
with:
retention-days: 1
name: oracle-free-${{ matrix.versions }}${{ steps.env_vars.outputs.IMAGE_FLAVOR }}-faststart-${{ steps.env_vars.outputs.IMAGE_ARCH }}
path: oracle-free-${{ matrix.versions }}${{ steps.env_vars.outputs.IMAGE_FLAVOR }}-faststart-${{ steps.env_vars.outputs.IMAGE_ARCH }}.tar
upload-platform-images:
name: ⬆️ 📋 Upload platform images to registries
environment: upload
runs-on: ubuntu-24.04
needs: [ set-constants, build-images ]
permissions:
packages: write
id-token: write
contents: read
attestations: write
strategy:
matrix:
versions: ${{ fromJSON(needs.set-constants.outputs.VERSIONS) }}
arch: ${{ fromJSON(needs.set-constants.outputs.IMAGE_ARCH) }}
flavor: [ "-full", "-slim", "" ] # "" is the "regular" image
steps:
- name: ⏬ Install build dependencies
run: sudo apt-get install -y buildah podman
- name: ⬇️ Download non-faststart image
uses: actions/download-artifact@v4
with:
name: oracle-free-${{ matrix.versions }}${{ matrix.flavor }}-${{ matrix.arch }}
- name: ⬇️ Download faststart image
uses: actions/download-artifact@v4
with:
name: oracle-free-${{ matrix.versions }}${{ matrix.flavor }}-faststart-${{ matrix.arch }}
- name: 📥 Import images
run: |
podman load -i oracle-free-${{ matrix.versions }}${{ matrix.flavor }}-${{ matrix.arch }}.tar
podman load -i oracle-free-${{ matrix.versions }}${{ matrix.flavor }}-faststart-${{ matrix.arch }}.tar
- name: Login to GHCR registry
uses: redhat-actions/podman-login@v1
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io/${{ github.repository_owner }}/test
- name: 🫸 Push non-faststart image to GitHub Container Registry
id: push-to-ghcr
uses: redhat-actions/push-to-registry@v2
with:
registry: ghcr.io/${{ github.repository_owner }}/test
image: oracle-free
tags: ${{ matrix.versions }}${{ matrix.flavor }}-${{ matrix.arch }}
- name: 🔄 Generate artifact attestation for non-faststart image
uses: actions/attest-build-provenance@v2
with:
subject-name: ghcr.io/gvenzl/test/oracle-free
subject-digest: ${{ steps.push-to-ghcr.outputs.digest }}
push-to-registry: true
- name: 🫸 Push faststart image to GitHub Container Registry
id: push-faststart-to-ghcr
uses: redhat-actions/push-to-registry@v2
with:
registry: ghcr.io/${{ github.repository_owner }}/test
image: oracle-free
tags: ${{ matrix.versions }}${{ matrix.flavor }}-faststart-${{ matrix.arch }}
- name: 🔄 Generate artifact attestation for faststart image
uses: actions/attest-build-provenance@v2
with:
subject-name: ghcr.io/gvenzl/test/oracle-free
subject-digest: ${{ steps.push-faststart-to-ghcr.outputs.digest }}
push-to-registry: true