Skip to content

Commit e7c86a3

Browse files
committed
ci(dir): extend security scanner to support more tag
Signed-off-by: Árpád Csepi <csepi.arpad@outlook.com>
1 parent 658407a commit e7c86a3

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

.github/workflows/container-security-scan.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
image-tag:
1212
required: false
1313
type: string
14-
description: "Override tag for repo images (empty for latest)"
14+
description: "Override tag for repo images (latest for latest release version)"
1515

1616
permissions:
1717
contents: read
@@ -20,8 +20,9 @@ permissions:
2020
issues: write # create issues for critical CVEs
2121

2222
jobs:
23-
resolve-tag:
24-
name: Resolve image tag
23+
resolve-latest-tag:
24+
if: ${{ github.event.inputs.image-tag == 'latest' }}
25+
name: Resolve latest release version tag
2526
runs-on: ubuntu-latest
2627
outputs:
2728
version: ${{ steps.resolve.outputs.version }}
@@ -53,10 +54,28 @@ jobs:
5354
echo "version=${TAG_VERSION}" >> $GITHUB_OUTPUT
5455
fi
5556
57+
build-from-main:
58+
if: ${{ github.event.inputs.image-tag == 'latest' && github.event.inputs.image-tag == '' }}
59+
name: Build main branch
60+
runs-on: ubuntu-latest
61+
outputs:
62+
main_sha: ${{ steps.get-commit-sha.outputs.main_sha }}
63+
steps:
64+
- name: Get main branch SHA
65+
id: get-commit-sha
66+
run: |
67+
MAIN_SHA=gh api repos/${{ github.repository }}/git/refs/heads/${{ github.event.repository.default_branch }} | jq -r .object.sha
68+
echo "main_sha=${MAIN_SHA}" >> $GITHUB_OUTPUT
69+
70+
- uses: ./.github/workflows/reusable-build.yaml
71+
with:
72+
image_repo: ghcr.io/agntcy
73+
image_tag: ${{ steps.get-commit-sha.outputs.main_sha }}
74+
5675
image-list:
5776
name: Resolve image list
5877
runs-on: ubuntu-latest
59-
needs: [resolve-tag]
78+
needs: [resolve-latest-tag, build-from-main]
6079
outputs:
6180
matrix: ${{ steps.matrix.outputs.matrix }}
6281
steps:
@@ -70,7 +89,7 @@ jobs:
7089
- name: Get image list from task
7190
id: matrix
7291
env:
73-
IMAGE_TAG: ${{ needs.resolve-tag.outputs.version }}
92+
IMAGE_TAG: ${{ needs.resolve-latest-tag.outputs.version || needs.build-from-main.outputs.main_sha || github.event.inputs.image-tag }}
7493
IMAGE_REPO: ghcr.io/${{ github.repository_owner }}
7594
run: |
7695
matrix=$(task --silent deps:vuln:images:list | jq -R -s -c 'split("\n") | map(select(length > 0)) | {image: .}')

0 commit comments

Comments
 (0)