Skip to content

Commit 017a0a1

Browse files
committed
make matrix job and pass over list
1 parent 0a5f721 commit 017a0a1

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

.github/workflows/scan.yaml

+20-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Scan all images
22
on: workflow_dispatch
33

44
jobs:
5-
scan:
5+
image_list:
66
runs-on: ubuntu-latest
77
steps:
88
- uses: actions/checkout@v4
@@ -17,5 +17,23 @@ jobs:
1717
run: curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
1818
- name: Install deps
1919
run: poetry install
20-
- name: Run scanner
20+
- name: scan
2121
run: poetry run python stack_scanner/main.py
22+
outputs:
23+
matrix: ${{ steps.scan.outputs.matrix }}
24+
25+
scan:
26+
needs: image_list
27+
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
package: ${{ fromJson(needs.image_list.outputs.matrix) }}
32+
steps:
33+
- name: Debug
34+
run: echo ${matrix.package}
35+
# - name: Scan image
36+
# uses: anchore/scan-action@v3
37+
# with:
38+
# image: "localbuild/testimage:latest"
39+
# - name: Upload report

stack_scanner/main.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
from urllib.request import urlretrieve
23
from image_tools.args import load_configuration
34
import tempfile
@@ -40,6 +41,7 @@ def main():
4041
# Load product versions from that file using the image-tools functionality
4142
product_versions = load_configuration(filename)
4243

44+
result = []
4345
# Generate image names
4446
product_names: list[str] = [product["name"] for product in product_versions.products]
4547
for product in product_versions.products:
@@ -53,7 +55,11 @@ def main():
5355
image_name = f"{REGISTRY_URL}/stackable/{product_name}:{product_version}-stackable{release}"
5456
#print(f"Scanning {REGISTRY_URL}/stackable/{product_name}:{product_version}-stackable{release}")
5557
print(f"grype -o cyclonedx --file {release}-{product_name}-{product_version}.cdx {image_name}")
56-
subprocess.run(["grype", "-o", "json", "--file", f"release-{product_name}-{product_version}.cdx", f"{image_name}"])
58+
#subprocess.run(["grype", "-o", "json", "--file", f"release-{product_name}-{product_version}.cdx", f"{image_name}"])
59+
result.append(image_name)
60+
61+
# All done
62+
print(f'::set-output name=matrix::{json.dumps(result)}')
5763

5864

5965

0 commit comments

Comments
 (0)