Upgrade run-time base image #114
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: tii-depthai-ctrl | |
on: | |
push: | |
pull_request: | |
repository_dispatch: | |
types: [fog-ros-baseimage-update] | |
workflow_dispatch: | |
inputs: | |
build_amd64: | |
description: 'Build for AMD64?' | |
required: true | |
default: true | |
type: boolean | |
build_arm64: | |
description: 'Build for ARM64?' | |
required: true | |
default: false | |
type: boolean | |
build_riscv64: | |
description: 'Build for RISCV64?' | |
required: true | |
default: false | |
type: boolean | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Determine platforms | |
id: platforms | |
run: | | |
platforms=('amd64' 'arm64' 'riscv64') | |
qemu_platforms="" | |
docker_platforms="" | |
if [[ "${{ github.event_name }}" != 'workflow_dispatch' || "${{ github.event.inputs.build_amd64 }}" == 'true' ]]; then | |
qemu_platforms+="amd64," | |
docker_platforms+="linux/amd64," | |
fi | |
if [[ "${{ github.event_name }}" != 'workflow_dispatch' || "${{ github.event.inputs.build_arm64 }}" == 'true' ]]; then | |
qemu_platforms+="arm64," | |
docker_platforms+="linux/arm64," | |
fi | |
if [[ "${{ github.event_name }}" != 'workflow_dispatch' || "${{ github.event.inputs.build_riscv64 }}" == 'true' ]]; then | |
qemu_platforms+="riscv64," | |
docker_platforms+="linux/riscv64," | |
fi | |
echo "qemu=${qemu_platforms%?}" >> $GITHUB_OUTPUT | |
echo "docker=${docker_platforms%?}" >> $GITHUB_OUTPUT | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: ${{ steps.platforms.outputs.qemu }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set image tag format without suffix | |
run: | | |
echo "IMAGE_TAG_FORMAT=type=sha" >> $GITHUB_ENV | |
if: github.event_name == 'push' | |
- name: Set image tag format with suffix | |
# it is possible that run_number should be used instead run_attempt | |
# run_attempt is unique number on every run and run_attempt resets to 1 if re-build is not used | |
# content of image_sha_tag_suffix is defined in fog-ros-baseimage dispatcher workflow. | |
run: | | |
echo "IMAGE_TAG_FORMAT=type=sha,suffix=-${{ github.event.client_payload.image_sha_tag_suffix }}" >> $GITHUB_ENV | |
if: github.event_name == 'repository_dispatch' | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/tiiuae/tii-depthai-ctrl | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
type=raw,value=latest | |
${{ env.IMAGE_TAG_FORMAT }} | |
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build container image and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: Dockerfile.multi-arch | |
platforms: ${{ steps.platforms.outputs.docker }} | |
push: true | |
no-cache: false | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |