Skip to content

Commit 874ea6d

Browse files
fix: improve fallback mechanism for scheduled vulnerability scan
Signed-off-by: kmilo <kmilo.denis.glez@yandex.com>
1 parent 8aec33b commit 874ea6d

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

‎.github/workflows/scheduled-scan.yml‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,26 @@ jobs:
2424
env:
2525
GH_TOKEN: ${{ github.token }}
2626
run: |
27-
tag="$(gh api "repos/${GITHUB_REPOSITORY}/releases/latest" --jq '.tag_name')"
27+
# Attempt to get the latest release tag from GitHub Releases API
28+
tag="$(gh api "repos/${GITHUB_REPOSITORY}/releases/latest" --jq '.tag_name' 2>/dev/null || echo "")"
29+
30+
# If no release (or API failed), try the repository tags list via the API
2831
if [ -z "${tag}" ] || [ "${tag}" = "null" ]; then
29-
echo "::error::No releases found in ${GITHUB_REPOSITORY}"
30-
exit 1
32+
tag="$(gh api "repos/${GITHUB_REPOSITORY}/tags" --jq '.[0].name' 2>/dev/null || echo "")"
33+
fi
34+
35+
# If still empty, log warning and use main branch as a safe default
36+
if [ -z "${tag}" ]; then
37+
echo "::warning::No releases or tags found in ${GITHUB_REPOSITORY}, using main branch for scan"
38+
tag="main"
3139
fi
40+
3241
echo "value=${tag}" >> "${GITHUB_OUTPUT}"
3342
43+
concurrency:
44+
group: ${{ github.workflow }}
45+
cancel-in-progress: false
46+
3447
scan-release:
3548
name: Scan ${{ needs.latest-release-version.outputs.tag_name }}
3649
needs: latest-release-version

0 commit comments

Comments
 (0)