Correct user mode #9
Workflow file for this run
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: Publish multi-arch Docker images | |
on: | |
push: | |
tags: | |
- "release/*" | |
- "feature/*" | |
- "daily/*" | |
- "v*" # release | |
- "f*" # feature | |
- "d*" # daily | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
base: ["jammy"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Prepare for docker build | |
run: | | |
ref_type=${{ github.ref_type }} | |
echo "REF_TYPE: ["$ref_type"]" | |
ref_name=${{ github.ref_name }} | |
echo "REF_NAME: ["$ref_name"]" | |
ref=${{ github.ref }} | |
echo "REF: ["$ref"]" | |
declare -A base_image_from_matrix | |
base_image_from_matrix[jammy]=ubuntu:jammy | |
select_base_image=${base_image_from_matrix[${{ matrix.base }}]} | |
if [ -z "${select_base_image}" ]; then | |
select_base_image=debian:buster-slim | |
fi | |
echo "Select Base Image [" $select_base_image "]" | |
image_name=${{secrets.DOCKER_USERNAME}}/mopidy | |
declare -A special_tags | |
special_tags[jammy]="${image_name}:stable,${image_name}:latest" | |
distro_id=${{ matrix.base }} | |
tags="" | |
if [ "${ref_type}" = "tag" ]; then | |
echo "tag mode"; | |
echo "tag is ["${ref_name}"]"; | |
if [[ "${ref_name}" = *"/"* ]]; then | |
tag_type=$(echo ${ref_name} | cut -d '/' -f 1) | |
tag_name=$(echo ${ref_name} | cut -d '/' -f 2) | |
else | |
if [[ "${ref_name}" = "v"* || "${ref_name}" = "f"* || "${ref_name}" = "d"* ]]; then | |
tag_type=${ref_name:0:1} | |
tag_name=${ref_name:1} | |
fi | |
fi | |
echo "tag_type=[$tag_type]" | |
echo "tag_name=[$tag_name]" | |
if [[ "${tag_type}" == "release" || "${tag_type}" == "v" ]]; then | |
echo "release tag"; | |
tags="$image_name:${distro_id}" | |
tags="$tags,$image_name:${distro_id}-${tag_name}" | |
select_special_tags=${special_tags["${distro_id}"]}; | |
if [[ -n "${select_special_tags}" ]]; then | |
echo "Found special tags for ["${distro_id}"]=["${select_special_tags}"]"; | |
tags="$tags,${select_special_tags}"; | |
else | |
echo "No special tag found for ["${distro_id}"]"; | |
fi | |
elif [[ "${tag_type}" == "feature" || "${tag_type}" == "f" ]]; then | |
echo "feature tag"; | |
tags="${image_name}:feature-${tag_name}-${distro_id}"; | |
elif [[ "${tag_type}" = "daily" || "${tag_type}" = "d" ]]; then | |
echo "daily build"; | |
tags="${image_name}:daily-${distro_id}"; | |
select_special_tags=${special_tags["${distro_id}"]}; | |
if [[ -n "${select_special_tags}" ]]; then | |
echo "Found special tags for ["${distro_id}"]=["${select_special_tags}"]"; | |
tags="$tags,${select_special_tags}"; | |
else | |
echo "No special tag found for ["${distro_id}"]"; | |
fi | |
fi | |
fi | |
echo "Building tags: ["${tags}"]" | |
echo "RELEASE_TAGS=${tags}" >> $GITHUB_ENV | |
echo "BASE_IMAGE=${select_base_image}" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
build-args: | | |
BASE_IMAGE=${{ env.BASE_IMAGE }} | |
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8 | |
push: true | |
tags: ${{ env.RELEASE_TAGS }} |