Skip to content

Merge branch 'main' of https://github.com/HIRO-MicroDataCenters-BV/rh… #100

Merge branch 'main' of https://github.com/HIRO-MicroDataCenters-BV/rh…

Merge branch 'main' of https://github.com/HIRO-MicroDataCenters-BV/rh… #100

Workflow file for this run

name: Build
on:
push:
branches:
- '**'
tags:
- '**'
paths-ignore:
- 'releases/**'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.ref == 'refs/heads/main' && 'hiro-microdatacenters-bv/rhio' || 'hiro-microdatacenters-bv/rhio-dev' }}
HELM_CHART_TARGET_DIR: ${{ github.ref == 'refs/heads/main' && './helm-charts' || './dev' }}
BRANCH_NAME: ${GITHUB_REF##*/}
jobs:
test:
name: Test / ${{ matrix.config.target }} on ${{ matrix.config.os }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: aarch64-apple-darwin
isMain:
- ${{ github.ref == 'refs/heads/main' }}
exclude:
- config:
os: macos-latest
target: aarch64-apple-darwin
isMain: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: moonrepo/setup-rust@v1
with:
channel: ${{ env.RUST_TOOLCHAIN }}
- name: Run tests
# Ensure debug output is also tested
env:
RUST_LOG: debug
run: cargo test --all-features
build-helm-chart:
name: Build Helm Chart
runs-on: ubuntu-latest
needs: [test]
defaults:
run:
working-directory: ./
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Helm
uses: azure/setup-helm@v3
- name: Make versions
run: |
cd "${{ github.workspace }}"
chmod +x ./version.sh
./version.sh "${{ github.sha }}" "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
echo "VERSION_APP=$(cat "./VERSION")" >> $GITHUB_ENV
echo "DOCKER_IMAGES=$(cat "./DOCKER_IMAGES")" >> $GITHUB_ENV
echo "DOCKER_TAGS=$(cat "./VERSION_DOCKER")" >> $GITHUB_ENV
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Create a github release
if: ${{ github.ref == 'refs/heads/main' }}
run: gh release create "${{ env.VERSION_APP }}"
env:
GH_TOKEN: ${{ github.token }}
- name: Publish Helm charts
uses: stefanprodan/helm-gh-pages@master
with:
token: ${{ github.token }}
charts_dir: "./charts"
target_dir: ${{ env.HELM_CHART_TARGET_DIR }}
build-docker:
name: Docker Build / ${{ matrix.platform }}
runs-on: ubuntu-latest
needs: [test]
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
isMain:
- ${{ github.ref == 'refs/heads/main' }}
exclude:
# ARM build is very slow, we build only for main branch
- platform: "linux/arm64"
isMain: false
defaults:
run:
working-directory: ./
permissions:
contents: write
packages: write
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.platform }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Make versions
run: |
cd "${{ github.workspace }}"
chmod +x ./version.sh
./version.sh "${{ github.sha }}" "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
echo "VERSION_APP=$(cat "./VERSION")" >> $GITHUB_ENV
echo "DOCKER_IMAGES=$(cat "./DOCKER_IMAGES")" >> $GITHUB_ENV
echo "DOCKER_TAGS=$(cat "./VERSION_DOCKER")" >> $GITHUB_ENV
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{ env.DOCKER_TAGS }}
- name: Build and push docker image
id: build
uses: docker/build-push-action@v6
with:
push: true
platforms: ${{ matrix.platform }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.DOCKER_TAGS }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=build-${{ env.PLATFORM_PAIR }}
cache-to: type=gha,mode=max,scope=build-${{ env.PLATFORM_PAIR }}
github-token: ${{ github.token }}
- name: Export Digest
run: |
digest="${{ steps.build.outputs.digest }}"
[ "$digest" ] || exit 1
mkdir -p /tmp/digests
touch "/tmp/digests/${digest#sha256:}"
- name: Upload Digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge-manifests:
name: Docker Build / Merge Manifests
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
needs:
- build-docker
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Make versions
run: |
cd "${{ github.workspace }}"
chmod +x ./version.sh
./version.sh "${{ github.sha }}" "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
echo "VERSION_APP=$(cat "./VERSION")" >> $GITHUB_ENV
echo "DOCKER_IMAGES=$(cat "./DOCKER_IMAGES")" >> $GITHUB_ENV
echo "DOCKER_TAGS=$(cat "./VERSION_DOCKER")" >> $GITHUB_ENV
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{ env.DOCKER_TAGS }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}