Skip to content

Commit 180e83b

Browse files
Move variables to a standalone file variables.yaml
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent 8b5d7f6 commit 180e83b

File tree

2 files changed

+93
-52
lines changed

2 files changed

+93
-52
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -28,58 +28,7 @@ concurrency:
2828

2929
jobs:
3030
variables:
31-
runs-on: ubuntu-latest
32-
outputs:
33-
commit_short_sha: ${{ steps.vars.outputs.commit_short_sha }}
34-
repo_full_name: ${{ steps.vars.outputs.repo_full_name }}
35-
label_image_source: ${{ steps.vars.outputs.label_image_source }}
36-
push_on_build: ${{ steps.vars.outputs.push_on_build }}
37-
operator_image_base: ${{ steps.vars.outputs.operator_image_base }}
38-
operator_version: ${{ steps.vars.outputs.operator_version }}
39-
steps:
40-
- name: Checkout code
41-
uses: actions/checkout@v5
42-
- name: Calculate all variables
43-
id: vars
44-
run: |
45-
# Basic computed values
46-
COMMIT_SHORT_SHA="${GITHUB_SHA:0:8}"
47-
48-
# Repository information
49-
REPO_FULL_NAME="${{ github.event.pull_request.head.repo.full_name }}"
50-
if [[ -z "${REPO_FULL_NAME}" ]]; then
51-
REPO_FULL_NAME="${{ github.repository }}"
52-
fi
53-
LABEL_IMAGE_SOURCE="https://github.com/${REPO_FULL_NAME}"
54-
55-
# Determine if we should push images
56-
PUSH_ON_BUILD="false"
57-
if [[ "${{ github.actor }}" != "dependabot[bot]" ]]; then
58-
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]]; then
59-
PUSH_ON_BUILD="true"
60-
elif [[ "${{ github.event_name }}" == "push" ]]; then
61-
PUSH_ON_BUILD="true"
62-
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
63-
PUSH_ON_BUILD="true"
64-
fi
65-
fi
66-
67-
# Image and version information
68-
OPERATOR_IMAGE_BASE="ghcr.io/nvidia/gpu-operator"
69-
OPERATOR_VERSION="${COMMIT_SHORT_SHA}"
70-
71-
# Output all variables
72-
echo "commit_short_sha=${COMMIT_SHORT_SHA}" >> $GITHUB_OUTPUT
73-
echo "repo_full_name=${REPO_FULL_NAME}" >> $GITHUB_OUTPUT
74-
echo "label_image_source=${LABEL_IMAGE_SOURCE}" >> $GITHUB_OUTPUT
75-
echo "push_on_build=${PUSH_ON_BUILD}" >> $GITHUB_OUTPUT
76-
echo "operator_image_base=${OPERATOR_IMAGE_BASE}" >> $GITHUB_OUTPUT
77-
echo "operator_version=${OPERATOR_VERSION}" >> $GITHUB_OUTPUT
78-
79-
# Display for debugging
80-
echo "::notice::Commit SHA: ${COMMIT_SHORT_SHA}"
81-
echo "::notice::Push on build: ${PUSH_ON_BUILD}"
82-
echo "::notice::Operator image: ${OPERATOR_IMAGE_BASE}:${OPERATOR_VERSION}"
31+
uses: ./.github/workflows/variables.yaml
8332

8433
code-scanning:
8534
uses: ./.github/workflows/code-scanning.yaml

.github/workflows/variables.yaml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Copyright 2025 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+
on:
16+
workflow_call:
17+
outputs:
18+
commit_short_sha:
19+
description: "The short SHA to use as a version string"
20+
value: ${{ jobs.variables.outputs.commit_short_sha }}
21+
repo_full_name:
22+
description: "The full repository name"
23+
value: ${{ jobs.variables.outputs.repo_full_name }}
24+
label_image_source:
25+
description: "The image source label URL"
26+
value: ${{ jobs.variables.outputs.label_image_source }}
27+
push_on_build:
28+
description: "Whether to push images on build"
29+
value: ${{ jobs.variables.outputs.push_on_build }}
30+
operator_image_base:
31+
description: "The base operator image name"
32+
value: ${{ jobs.variables.outputs.operator_image_base }}
33+
operator_version:
34+
description: "The operator version"
35+
value: ${{ jobs.variables.outputs.operator_version }}
36+
37+
jobs:
38+
variables:
39+
runs-on: ubuntu-latest
40+
outputs:
41+
commit_short_sha: ${{ steps.vars.outputs.commit_short_sha }}
42+
repo_full_name: ${{ steps.vars.outputs.repo_full_name }}
43+
label_image_source: ${{ steps.vars.outputs.label_image_source }}
44+
push_on_build: ${{ steps.vars.outputs.push_on_build }}
45+
operator_image_base: ${{ steps.vars.outputs.operator_image_base }}
46+
operator_version: ${{ steps.vars.outputs.operator_version }}
47+
steps:
48+
- name: Checkout code
49+
uses: actions/checkout@v5
50+
51+
- name: Calculate all variables
52+
id: vars
53+
run: |
54+
# Basic computed values
55+
COMMIT_SHORT_SHA="${GITHUB_SHA:0:8}"
56+
57+
# Repository information
58+
REPO_FULL_NAME="${{ github.event.pull_request.head.repo.full_name }}"
59+
if [[ -z "${REPO_FULL_NAME}" ]]; then
60+
REPO_FULL_NAME="${{ github.repository }}"
61+
fi
62+
LABEL_IMAGE_SOURCE="https://github.com/${REPO_FULL_NAME}"
63+
64+
# Determine if we should push images
65+
PUSH_ON_BUILD="false"
66+
if [[ "${{ github.actor }}" != "dependabot[bot]" ]]; then
67+
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]]; then
68+
PUSH_ON_BUILD="true"
69+
elif [[ "${{ github.event_name }}" == "push" ]]; then
70+
PUSH_ON_BUILD="true"
71+
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
72+
PUSH_ON_BUILD="true"
73+
fi
74+
fi
75+
76+
# Image and version information
77+
OPERATOR_IMAGE_BASE="ghcr.io/nvidia/gpu-operator"
78+
OPERATOR_VERSION="${COMMIT_SHORT_SHA}"
79+
80+
# Output all variables
81+
echo "commit_short_sha=${COMMIT_SHORT_SHA}" >> $GITHUB_OUTPUT
82+
echo "repo_full_name=${REPO_FULL_NAME}" >> $GITHUB_OUTPUT
83+
echo "label_image_source=${LABEL_IMAGE_SOURCE}" >> $GITHUB_OUTPUT
84+
echo "push_on_build=${PUSH_ON_BUILD}" >> $GITHUB_OUTPUT
85+
echo "operator_image_base=${OPERATOR_IMAGE_BASE}" >> $GITHUB_OUTPUT
86+
echo "operator_version=${OPERATOR_VERSION}" >> $GITHUB_OUTPUT
87+
88+
# Display for debugging
89+
echo "::notice::Commit SHA: ${COMMIT_SHORT_SHA}"
90+
echo "::notice::Push on build: ${PUSH_ON_BUILD}"
91+
echo "::notice::Operator image: ${OPERATOR_IMAGE_BASE}:${OPERATOR_VERSION}"
92+

0 commit comments

Comments
 (0)