forked from eclipse-velocitas/vehicle-app-cpp-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (83 loc) · 2.76 KB
/
sdk-build-container.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# 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: .