OIDC refactor dockerfiles #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: start-linux-multiarch | |
on: | |
pull_request: | |
branches: | |
- master | |
- oidc | |
push: | |
branches: | |
- '2024.06' | |
merge_group: | |
concurrency: ci-multiarch-${{ github.ref }} | |
# REQUIRED global variables | |
# DOCKER_ORG, docker org used for pushing images. | |
env: | |
# [OIDC] Required for pushing images to ghcr.io | |
DOCKER_ORG: ghcr.io/heviat | |
jobs: | |
# This job calculates all global job variables that are required by all the subsequent jobs. | |
# All subsequent jobs will retrieve and use these variables. This way the variables only have to be derived once. | |
derive-variables: | |
name: derive variables | |
runs-on: ubuntu-latest | |
outputs: | |
MAILU_VERSION: ${{ env.MAILU_VERSION }} | |
PINNED_MAILU_VERSION: ${{ env.PINNED_MAILU_VERSION }} | |
DOCKER_ORG: ${{ env.DOCKER_ORG_DERIVED }} | |
BRANCH: ${{ env.BRANCH}} | |
DEPLOY: ${{ env.DEPLOY }} | |
RELEASE: ${{ env.RELEASE }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# fetch-depth 0 is required to also retrieve all tags. | |
fetch-depth: 0 | |
- name: Extract branch name | |
shell: bash | |
run: | | |
echo "BRANCH=${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
- name: Derive MAILU_VERSION and DEPLOY/RELEASE for development branches | |
shell: bash | |
env: | |
BRANCH: ${{ github.ref_name }} | |
run: | | |
echo "MAILU_VERSION="${BRANCH////-} >> $GITHUB_ENV | |
echo "DOCKER_ORG_DERIVED=${{ env.DOCKER_ORG }}" >> $GITHUB_ENV | |
echo "DEPLOY=true" >> $GITHUB_ENV | |
echo "RELEASE=false" >> $GITHUB_ENV | |
- name: Derive PINNED_MAILU_VERSION and DEPLOY/RELEASE for normal release x.y | |
if: env.BRANCH != 'testing' && env.BRANCH != 'staging' && env.BRANCH != 'master' && !(contains(env.BRANCH, 'test-')) | |
shell: bash | |
run: | | |
version=$( git tag --sort=version:refname --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV | |
echo "DEPLOY=true" >> $GITHUB_ENV | |
echo "RELEASE=true" >> $GITHUB_ENV | |
- name: Derive PINNED_MAILU_VERSION and DEPLOY/RELEASE for staging | |
id: deploy | |
if: env.BRANCH == 'staging' | |
shell: bash | |
run: | | |
echo "PINNED_MAILU_VERSION=staging" >> $GITHUB_ENV | |
echo "DEPLOY=false" >> $GITHUB_ENV | |
echo "RELEASE=false" >> $GITHUB_ENV | |
- name: Derive PINNED_MAILU_VERSION for master | |
if: env.BRANCH == 'master' | |
shell: bash | |
env: | |
GITHUB_SHA: ${{ env.GITHUB_SHA }} | |
run: | | |
echo "PINNED_MAILU_VERSION=$GITHUB_SHA" >> $GITHUB_ENV | |
echo "DEPLOY=true" >> $GITHUB_ENV | |
echo "RELEASE=false" >> $GITHUB_ENV | |
- name: Derive for branch test-* | |
if: contains(env.BRANCH, 'test-') | |
run: | | |
echo "MAILU_VERSION=${{ env.BRANCH }}" >> $GITHUB_ENV | |
echo "PINNED_MAILU_VERSION=${{ env.BRANCH }}" >> $GITHUB_ENV | |
echo "DOCKER_ORG_DERIVED=${{ env.DOCKER_ORG }}" >> $GITHUB_ENV | |
echo "DEPLOY=true" >> $GITHUB_ENV | |
echo "RELEASE=false" >> $GITHUB_ENV | |
build-test-deploy: | |
needs: | |
- derive-variables | |
uses: ./.github/workflows/build_test_deploy.yml | |
with: | |
# linux/arm64/v8,linux/arm/v7 will be added when GitHub hosted arm64 runners are available by the end of 2024 | |
# https://github.blog/news-insights/product-news/arm64-on-github-actions-powering-faster-more-efficient-build-systems/ | |
architecture: 'linux/amd64' | |
mailu_version: ${{needs.derive-variables.outputs.MAILU_VERSION}} | |
pinned_mailu_version: ${{needs.derive-variables.outputs.PINNED_MAILU_VERSION}} | |
docker_org: ${{needs.derive-variables.outputs.DOCKER_ORG}} | |
branch: ${{needs.derive-variables.outputs.BRANCH}} | |
deploy: ${{needs.derive-variables.outputs.DEPLOY}} | |
release: ${{needs.derive-variables.outputs.RELEASE}} | |
secrets: inherit | |
################################################ | |
# Code block that is used as one liner for the step: | |
# Derive PINNED_MAILU_VERSION and DEPLOY/RELEASE for normal release x.y | |
##!/bin/bash | |
#version=$( git tag --sort=version:refname --list "{{ env.MAILU_VERSION }}.*" | tail -1 ) | |
#root_version=${version%.*} | |
#patch_version=${version##*.} | |
#if [ "$patch_version" == "" ] | |
#then | |
# pinned_version={{ env.MAILU_VERSION }}.0 | |
#else | |
# pinned_version=$root_version.$(expr $patch_version + 1) | |
#fi | |
#echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV |