Print with color in controller (#176) #2
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: Build and publish multi-arch container images | |
on: | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
inputs: | |
reason: | |
description: 'Reason for manual trigger' | |
required: true | |
default: '' | |
jobs: | |
ghcr_build_and_push: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' || github.event.inputs.reason != '' | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log-in to ghcr.io | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Build and push multi-arch container images | |
run: | | |
# set env for fork repo | |
DOCKER_BUILD_ORG=$(echo "${{ github.repository }}" | tr '[A-Z]' '[a-z]' | cut -d '/' -f 1) | |
# Find directories containing Dockerfile but not containing .dockerfileignore | |
while IFS= read -r dockerfile_dir; do | |
# Check if .dockerfileignore exists in the directory | |
if [ -f "$dockerfile_dir/.dockerfileignore" ]; then | |
echo "$dockerfile_dir/.dockerfileignore exists, skipping build and push" | |
continue | |
fi | |
# Check if image was already exist in ghcr.io | |
pushd "$dockerfile_dir" > /dev/null | |
FULL_IMAGE=$(make get-full-image DOCKER_BUILD_ORG=$DOCKER_BUILD_ORG) | |
popd > /dev/null | |
EXISTS=$(docker manifest inspect "$FULL_IMAGE" > /dev/null 2>&1 && echo "true" || echo "false") | |
if [ "$EXISTS" == "true" ]; then | |
echo "Image $FULL_IMAGE already exists in ghcr.io, skipping build and push" | |
continue | |
fi | |
# Build and push the image to ghcr.io | |
pushd "$dockerfile_dir" > /dev/null | |
make all DOCKER_BUILD_ORG=$DOCKER_BUILD_ORG | |
popd > /dev/null | |
done < <(find . -type f -name Dockerfile -exec dirname {} \; | sort -u) |