Skip to content

Commit 87be0dd

Browse files
[no-relnote] COnfigure all GitHub actions as reusable workflow
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent fa1379c commit 87be0dd

File tree

5 files changed

+97
-49
lines changed

5 files changed

+97
-49
lines changed

.github/workflows/ci.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
name: CI Pipeline
16+
17+
on:
18+
push:
19+
branches:
20+
- "pull-request/[0-9]+"
21+
- main
22+
- release-*
23+
24+
jobs:
25+
code-scanning:
26+
uses: ./.github/workflows/code_scanning.yaml
27+
28+
prepare-variables:
29+
needs: code-scanning
30+
runs-on: ubuntu-latest
31+
outputs:
32+
version: ${{ steps.version.outputs.version }}
33+
build_multi_arch_images: ${{ steps.build_multi_arch_images.outputs.value }}
34+
steps:
35+
- name: Generate Commit Short SHA
36+
id: version
37+
run: echo "version=$(echo $GITHUB_SHA | cut -c1-8)" >> "$GITHUB_OUTPUT"
38+
39+
- name: Determine Multi-Arch Build Setting
40+
id: build_multi_arch_images
41+
run: |
42+
if [[ "${{ github.ref_name != 'main' && !startsWith(github.ref_name, 'release-') }}" == "true" ]]; then
43+
echo "build_multi_arch_images=false" >> $GITHUB_OUTPUT
44+
else
45+
echo "build_multi_arch_images=true" >> $GITHUB_OUTPUT
46+
fi
47+
48+
golang:
49+
needs: code-scanning
50+
uses: ./.github/workflows/golang.yaml
51+
52+
image:
53+
uses: ./.github/workflows/image.yaml
54+
needs: prepare-variables
55+
secrets: inherit
56+
with:
57+
version: ${{ needs.prepare-variables.outputs.version }}
58+
build_multi_arch_images: ${{ needs.prepare-variables.outputs.build_multi_arch_images }}
59+
push_on_build: "true"
60+
61+
e2e-test:
62+
needs: image
63+
secrets: inherit
64+
uses: ./.github/workflows/e2e.yaml
65+
with:
66+
version: ${{ needs.prepare-variables.outputs.version }}

.github/workflows/code_scanning.yaml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,7 @@
1515
name: "CodeQL"
1616

1717
on:
18-
pull_request:
19-
types:
20-
- opened
21-
- synchronize
22-
branches:
23-
- main
24-
- release-*
25-
push:
26-
branches:
27-
- main
28-
- release-*
18+
workflow_call:
2919

3020
jobs:
3121
analyze:

.github/workflows/e2e.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ name: End-to-end Tests
1616

1717
on:
1818
workflow_call:
19-
inputs: {}
19+
inputs:
20+
version:
21+
required: true
22+
type: string
2023
secrets:
2124
AWS_ACCESS_KEY_ID:
2225
required: true
@@ -67,8 +70,8 @@ jobs:
6770

6871
- name: Run e2e tests
6972
env:
70-
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/container-toolkit
71-
VERSION: ${COMMIT_SHORT_SHA}
73+
IMAGE_NAME: ghcr.io/nvidia/container-toolkit
74+
VERSION: ${{ steps.vars.outputs.version }}
7275
SSH_KEY: ${{ secrets.AWS_SSH_KEY }}
7376
E2E_SSH_USER: ${{ secrets.E2E_SSH_USER }}
7477
E2E_SSH_HOST: ${{ steps.holodeck_public_dns_name.outputs.result }}

.github/workflows/golang.yaml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,7 @@
1515
name: Golang
1616

1717
on:
18-
pull_request:
19-
types:
20-
- opened
21-
- synchronize
22-
branches:
23-
- main
24-
- release-*
25-
push:
26-
branches:
27-
- main
28-
- release-*
18+
workflow_call:
2919

3020
jobs:
3121
check:

.github/workflows/image.yaml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@
1616
name: image
1717

1818
on:
19-
push:
20-
branches:
21-
- "pull-request/[0-9]+"
22-
- main
23-
- release-*
19+
workflow_call:
20+
inputs:
21+
version:
22+
required: true
23+
type: string
24+
build_multi_arch_images:
25+
required: true
26+
type: string
27+
push_on_build:
28+
required: true
29+
type: string
2430

2531
jobs:
2632
packages:
@@ -46,20 +52,25 @@ jobs:
4652
- ispr: true
4753
target: centos8-ppc64le
4854
fail-fast: false
55+
4956
steps:
5057
- uses: actions/checkout@v4
5158
name: Check out code
59+
5260
- name: Set up QEMU
5361
uses: docker/setup-qemu-action@v3
5462
with:
5563
image: tonistiigi/binfmt:master
64+
5665
- name: Set up Docker Buildx
5766
uses: docker/setup-buildx-action@v3
67+
5868
- name: build ${{ matrix.target }} packages
5969
run: |
6070
sudo apt-get install -y coreutils build-essential sed git bash make
6171
echo "Building packages"
6272
./scripts/build-packages.sh ${{ matrix.target }}
73+
6374
- name: 'Upload Artifacts'
6475
uses: actions/upload-artifact@v4
6576
with:
@@ -84,24 +95,15 @@ jobs:
8495
steps:
8596
- uses: actions/checkout@v4
8697
name: Check out code
87-
- name: Calculate build vars
88-
id: vars
89-
run: |
90-
echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
91-
echo "LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_ENV
9298

93-
BUILD_MULTI_ARCH_IMAGES="true"
94-
if [[ "${{ matrix.ispr }}" == "true" ]]; then
95-
BUILD_MULTI_ARCH_IMAGES="false"
96-
fi
97-
echo "PUSH_ON_BUILD=true" >> $GITHUB_ENV
98-
echo "BUILD_MULTI_ARCH_IMAGES=${BUILD_MULTI_ARCH_IMAGES}" >> $GITHUB_ENV
9999
- name: Set up QEMU
100100
uses: docker/setup-qemu-action@v3
101101
with:
102102
image: tonistiigi/binfmt:master
103+
103104
- name: Set up Docker Buildx
104105
uses: docker/setup-buildx-action@v3
106+
105107
- name: Get built packages
106108
uses: actions/download-artifact@v4
107109
with:
@@ -115,16 +117,13 @@ jobs:
115117
registry: ghcr.io
116118
username: ${{ github.actor }}
117119
password: ${{ secrets.GITHUB_TOKEN }}
120+
118121
- name: Build image
119122
env:
120-
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/container-toolkit
121-
VERSION: ${COMMIT_SHORT_SHA}
123+
IMAGE_NAME: ghcr.io/nvidia/container-toolkit
124+
VERSION: ${{ inputs.version }}
125+
PUSH_ON_BUILD: ${{ inputs.push_on_build }}
126+
BUILD_MULTI_ARCH_IMAGES: ${{ inputs.build_multi_arch_images }}
122127
run: |
123128
echo "${VERSION}"
124129
make -f deployments/container/Makefile build-${{ matrix.dist }}
125-
126-
test:
127-
name: End-to-end Tests
128-
uses: ./.github/workflows/e2e.yaml
129-
secrets: inherit
130-
needs: image

0 commit comments

Comments
 (0)