Skip to content

Commit 8e27ec1

Browse files
committed
Add Github Actions workflow for building images
Signed-off-by: Christopher Desiniotis <[email protected]>
1 parent 0c2c9cb commit 8e27ec1

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

.github/workflows/image.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright 2024 NVIDIA CORPORATION
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Image
16+
17+
on:
18+
pull_request:
19+
types:
20+
- opened
21+
- synchronize
22+
branches:
23+
- master
24+
- release-*
25+
push:
26+
branches:
27+
- master
28+
- release-*
29+
30+
jobs:
31+
build-gpu-operator:
32+
runs-on: ubuntu-latest
33+
strategy:
34+
matrix:
35+
dist: [ubi8]
36+
steps:
37+
- uses: actions/checkout@v4
38+
name: Check out code
39+
- name: Calculate build vars
40+
id: vars
41+
run: |
42+
echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
43+
echo "LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_ENV
44+
REPO_FULL_NAME="${{ github.event.pull_request.head.repo.full_name }}"
45+
echo "${REPO_FULL_NAME}"
46+
echo "LABEL_IMAGE_SOURCE=https://github.com/${REPO_FULL_NAME}" >> $GITHUB_ENV
47+
48+
GENERATE_ARTIFACTS="false"
49+
if [[ "${{ github.actor }}" == "dependabot[bot]" ]]; then
50+
GENERATE_ARTIFACTS="false"
51+
elif [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]]; then
52+
GENERATE_ARTIFACTS="true"
53+
elif [[ "${{ github.event_name }}" == "push" ]]; then
54+
GENERATE_ARTIFACTS="true"
55+
fi
56+
echo "PUSH_ON_BUILD=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV
57+
echo "BUILD_MULTI_ARCH_IMAGES=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV
58+
- name: Set up QEMU
59+
uses: docker/setup-qemu-action@v3
60+
- name: Set up Docker Buildx
61+
uses: docker/setup-buildx-action@v3
62+
- name: Login to GitHub Container Registry
63+
uses: docker/login-action@v3
64+
with:
65+
registry: ghcr.io
66+
username: ${{ github.actor }}
67+
password: ${{ secrets.GITHUB_TOKEN }}
68+
- name: Build image
69+
env:
70+
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/gpu-operator
71+
VERSION: ${COMMIT_SHORT_SHA}
72+
run: |
73+
echo "${VERSION}"
74+
make build-${{ matrix.dist }}

0 commit comments

Comments
 (0)