-
Notifications
You must be signed in to change notification settings - Fork 475
126 lines (115 loc) · 5.05 KB
/
variables.yaml
File metadata and controls
126 lines (115 loc) · 5.05 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Copyright NVIDIA CORPORATION
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://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.
name: CI Variables
on:
workflow_call:
inputs:
operator_image:
description: 'Operator image to use (optional override)'
required: false
type: string
operator_version:
description: 'Operator version to use (optional override)'
required: false
type: string
outputs:
commit_short_sha:
description: "The short SHA to use as a version string"
value: ${{ jobs.variables.outputs.commit_short_sha }}
repo_full_name:
description: "The full repository name"
value: ${{ jobs.variables.outputs.repo_full_name }}
label_image_source:
description: "The image source label URL"
value: ${{ jobs.variables.outputs.label_image_source }}
push_on_build:
description: "Whether to push images on build"
value: ${{ jobs.variables.outputs.push_on_build }}
operator_image_base:
description: "The base operator image name"
value: ${{ jobs.variables.outputs.operator_image_base }}
operator_version:
description: "The operator version"
value: ${{ jobs.variables.outputs.operator_version }}
operator_image:
description: "The operator image (with override support)"
value: ${{ jobs.variables.outputs.operator_image }}
jobs:
variables:
runs-on: ubuntu-latest
outputs:
commit_short_sha: ${{ steps.vars.outputs.commit_short_sha }}
repo_full_name: ${{ steps.vars.outputs.repo_full_name }}
label_image_source: ${{ steps.vars.outputs.label_image_source }}
push_on_build: ${{ steps.vars.outputs.push_on_build }}
operator_image_base: ${{ steps.vars.outputs.operator_image_base }}
operator_version: ${{ steps.vars.outputs.operator_version }}
operator_image: ${{ steps.vars.outputs.operator_image }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Calculate all variables
id: vars
env:
INPUT_OPERATOR_VERSION: ${{ inputs.operator_version }}
INPUT_OPERATOR_IMAGE: ${{ inputs.operator_image }}
PR_REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
GH_REPOSITORY: ${{ github.repository }}
GH_ACTOR: ${{ github.actor }}
GH_EVENT_NAME: ${{ github.event_name }}
run: |
# Basic computed values
COMMIT_SHORT_SHA="${GITHUB_SHA:0:8}"
# Repository information
REPO_FULL_NAME="${PR_REPO_FULL_NAME}"
if [[ -z "${REPO_FULL_NAME}" ]]; then
REPO_FULL_NAME="${GH_REPOSITORY}"
fi
LABEL_IMAGE_SOURCE="https://github.com/${REPO_FULL_NAME}"
# Determine if we should push images
PUSH_ON_BUILD="false"
if [[ "${GH_ACTOR}" != "dependabot[bot]" ]]; then
if [[ "${GH_EVENT_NAME}" == "pull_request" && "${PR_REPO_FULL_NAME}" == "${GH_REPOSITORY}" ]]; then
PUSH_ON_BUILD="true"
elif [[ "${GH_EVENT_NAME}" == "push" ]]; then
PUSH_ON_BUILD="true"
elif [[ "${GH_EVENT_NAME}" == "workflow_dispatch" ]]; then
PUSH_ON_BUILD="true"
fi
fi
# Image and version information (with override support)
LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')
OPERATOR_IMAGE_BASE="ghcr.io/${LOWERCASE_REPO_OWNER}/gpu-operator"
if [[ -n "${INPUT_OPERATOR_VERSION}" ]]; then
OPERATOR_VERSION="${INPUT_OPERATOR_VERSION}"
else
OPERATOR_VERSION="${COMMIT_SHORT_SHA}"
fi
if [[ -n "${INPUT_OPERATOR_IMAGE}" ]]; then
OPERATOR_IMAGE="${INPUT_OPERATOR_IMAGE}"
else
OPERATOR_IMAGE="${OPERATOR_IMAGE_BASE}"
fi
# Output all variables
echo "commit_short_sha=${COMMIT_SHORT_SHA}" >> $GITHUB_OUTPUT
echo "repo_full_name=${REPO_FULL_NAME}" >> $GITHUB_OUTPUT
echo "label_image_source=${LABEL_IMAGE_SOURCE}" >> $GITHUB_OUTPUT
echo "push_on_build=${PUSH_ON_BUILD}" >> $GITHUB_OUTPUT
echo "operator_image_base=${OPERATOR_IMAGE_BASE}" >> $GITHUB_OUTPUT
echo "operator_version=${OPERATOR_VERSION}" >> $GITHUB_OUTPUT
echo "operator_image=${OPERATOR_IMAGE}" >> $GITHUB_OUTPUT
# Display for debugging
echo "::notice::Commit SHA: ${COMMIT_SHORT_SHA}"
echo "::notice::Push on build: ${PUSH_ON_BUILD}"
echo "::notice::Operator image: ${OPERATOR_IMAGE}:${OPERATOR_VERSION}"