ci: probe Dependency graph before dependency-review - warn and pass when unavailable

The upstream PR run showed Dependency graph is disabled on the upstream
repo too (the action hard-fails: 'Dependency review is not supported on
this repository'), not just on forks. Only the repo owner can enable it,
so a hard red X here is friction, not signal.

The job now probes the dependency-graph SBOM endpoint with the workflow
token first: HTTP 200 runs the real review; anything else emits a
::warning:: naming the setting to flip (Settings -> Advanced Security ->
Dependency graph) and passes. Same graceful-skip pattern the workflow
uses for optional tools - the check self-activates the moment the graph
is enabled, no workflow change needed.
This commit is contained in:
ayobamiseun
2026-07-08 23:51:51 +01:00
parent 822c67ca55
commit 2a6cb8cfec
+22 -4
View File
@@ -56,14 +56,32 @@ jobs:
dependency-review:
name: Dependency review (upstream PRs only)
# Requires the repo's Dependency graph (enabled by default on public
# repos, but NOT on forks) - so this runs only on PRs to the upstream
# repo, same pattern as the other upstream-only jobs.
# Requires the repo's Dependency graph, which forks never inherit and
# which may be disabled upstream - so: upstream PRs only, and the
# graph is probed first. If it is unavailable, the job warns and
# passes instead of hard-failing (the same graceful-skip pattern the
# workflow uses for optional tools). Enabling Dependency graph under
# Settings -> Advanced Security activates the real check.
if: github.event_name == 'pull_request' && github.repository == 'MadsLorentzen/ai-job-search'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48 # v4.9.0
- name: Probe Dependency graph availability
id: graph
run: |
code=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/${{ github.repository }}/dependency-graph/sbom")
if [ "$code" = "200" ]; then
echo "enabled=true" >> "$GITHUB_OUTPUT"
else
echo "enabled=false" >> "$GITHUB_OUTPUT"
echo "::warning::Dependency graph is not enabled on this repository (HTTP $code). Dependency review was skipped - enable Dependency graph under Settings -> Advanced Security to activate this check."
fi
- name: Dependency review
if: steps.graph.outputs.enabled == 'true'
uses: actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48 # v4.9.0
with:
fail-on-severity: high