Skip to content

Improve base container #24

Improve base container

Improve base container #24

# Copyright (c) 2022-2023 Robert Bosch GmbH
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
name: SDK - App Builder
concurrency:
group: sdk-app-builder-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-container:
name: Building image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: github-repository-name-case-adjusted
name: Prepare repository name in lower case for docker upload.
uses: ASzc/change-string-case-action@v5
with:
string: ${{ github.repository }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
- name: Get image tag
id: get-tag
shell: bash
run: |
BASE=${{ steps.github-repository-name-case-adjusted.outputs.lowercase }}/app-builder
TAGS=$BASE:${{ github.sha }}
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
TAGS="${TAGS},$BASE:latest"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Set container output type
id: container_output
shell: bash
run: |
if [ ${{ github.event }} = "push" ]; then
echo "type=registry" >> $GITHUB_OUTPUT
else
echo "type=oci,dest=./container.tar" >> $GITHUB_OUTPUT
fi
- name: Build image
id: image_build
uses: docker/build-push-action@v3.2.0
with:
tags: ${{ steps.get-tag.outputs.tags }}
file: sdk/Dockerfile
platforms: linux/amd64
labels: ${{ steps.meta.outputs.labels }}
outputs: |
type=${{ steps.container_output.outputs.type }}
context: .