Skip to content

Commit 0ea389d

Browse files
committed
Backport image scan patch
1 parent 9953157 commit 0ea389d

File tree

3 files changed

+69
-7
lines changed

3 files changed

+69
-7
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: Create output for `runs-on` variable
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
runner_env:
8+
description: 'The environment input from caller workflow'
9+
default: 'SMS Lab'
10+
required: True
11+
type: string
12+
outputs:
13+
runner_name_image_build:
14+
description: "Image builder runner name"
15+
value: ${{ jobs.define_runner.outputs.image-build-runner }}
16+
runner_name_container_image_build:
17+
description: "Container image build runner name"
18+
value: ${{ jobs.define_runner.outputs.container-image-build-runner }}
19+
runner_name_aio:
20+
description: "AiO runner name"
21+
value: ${{ jobs.define_runner.outputs.aio-runner }}
22+
23+
jobs:
24+
define_runner:
25+
environment: ${{ inputs.runner_env }}
26+
runs-on: ubuntu-latest
27+
outputs:
28+
image-build-runner: ${{ steps.builder-runner.outputs.runner_name_image_build }}
29+
container-image-build-runner: ${{ steps.container-image-build-runner.outputs.runner_name_container_image_build }}
30+
aio-runner: ${{ steps.aio-runner.outputs.runner_name_aio }}
31+
steps:
32+
- name: Set output for image builder runner
33+
run: echo "Setting runner for ${{ inputs.runner_env }} -> ${{ vars.RUNS_ON_TARGET_IMAGE_BUILDER }}"
34+
35+
- id: builder-runner
36+
run: echo "runner_name_image_build=${{ vars.RUNS_ON_TARGET_IMAGE_BUILDER }}" >> $GITHUB_OUTPUT
37+
38+
- name: Set output for container image build runner
39+
run: echo "Setting runner for ${{ inputs.runner_env }} -> ${{ vars.RUNS_ON_TARGET_CONTAINER_IMAGE_BUILDER }}"
40+
41+
- id: container-image-build-runner
42+
run: echo "runner_name_container_image_build=${{ vars.RUNS_ON_TARGET_CONTAINER_IMAGE_BUILDER }}" >> $GITHUB_OUTPUT
43+
44+
- name: Set output for aio runner
45+
run: echo "Setting runner for ${{ inputs.runner_env }} -> ${{ vars.RUNS_ON_TARGET_AIO }}"
46+
47+
- id: aio-runner
48+
run: echo "runner_name_aio=${{ vars.RUNS_ON_TARGET_AIO }}" >> $GITHUB_OUTPUT

.github/workflows/stackhpc-container-image-build.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ on:
3838
type: boolean
3939
required: false
4040
default: false
41+
runner_env:
42+
description: Which cloud to run on?
43+
type: choice
44+
default: SMS Lab
45+
options:
46+
- SMS Lab
47+
- Leafcloud
4148

4249
env:
4350
ANSIBLE_FORCE_COLOR: True
@@ -101,10 +108,15 @@ jobs:
101108
run: |
102109
echo "${{ steps.datetime_tag.outputs.datetime_tag }}"
103110
111+
runner-selection:
112+
uses: ./.github/workflows/runner-selector.yml
113+
with:
114+
runner_env: ${{ inputs.runner_env }}
115+
104116
container-image-build:
105117
name: Build Kolla container images
106118
if: github.repository == 'stackhpc/stackhpc-kayobe-config'
107-
runs-on: arc-skc-container-image-builder-runner
119+
runs-on: ${{ needs.runner-selection.outputs.runner_name_container_image_build }}
108120
timeout-minutes: 720
109121
permissions: {}
110122
strategy:
@@ -144,7 +156,7 @@ jobs:
144156
145157
- name: Install Trivy
146158
run: |
147-
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sudo sh -s -- -b /usr/local/bin v0.49.0
159+
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sudo sh -s -- -b /usr/local/bin v0.67.2
148160
149161
- name: Install yq
150162
run: |
@@ -164,7 +176,7 @@ jobs:
164176
- name: Install Docker Python SDK
165177
run: |
166178
sudo pip install docker 'requests<2.32.0'
167-
179+
168180
- name: Get Kolla tag
169181
id: write-kolla-tag
170182
run: echo "kolla-tag=${{ needs.generate-tag.outputs.openstack_release }}-${{ matrix.distro }}-${{ matrix.distro == 'rocky' && '9' || 'jammy' }}-${{ needs.generate-tag.outputs.datetime_tag }}" >> $GITHUB_OUTPUT

tools/scan-images.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -u
1111

1212
# Check that trivy is installed
1313
if ! trivy --version; then
14-
echo 'Please install trivy: curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.49.1'
14+
echo 'Please install trivy: curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.67.2'
1515
fi
1616

1717
# Clear any previous outputs
@@ -21,10 +21,12 @@ rm -rf image-scan-output
2121
mkdir -p image-scan-output
2222

2323
# Get built container images
24-
docker image ls --filter "reference=ark.stackhpc.com/stackhpc-dev/*:$2" > $1-scanned-container-images.txt
24+
images=$(docker image ls \
25+
--filter "reference=ark.stackhpc.com/stackhpc-dev/*:$2*" \
26+
--format "{{.Repository}}:{{.Tag}}")
2527

26-
# Make a file of imagename:tag
27-
images=$(grep --invert-match --no-filename ^REPOSITORY $1-scanned-container-images.txt | sed 's/ \+/:/g' | cut -f 1,2 -d:)
28+
# Save list of images to file
29+
echo "$images" > "$1-scanned-container-images.txt"
2830

2931
# Ensure output files exist
3032
touch image-scan-output/clean-images.txt image-scan-output/dirty-images.txt image-scan-output/critical-images.txt

0 commit comments

Comments
 (0)