Skip to content

Commit 8aebbb4

Browse files
MusaMistodependabot-rollout-bot
andauthored
chore: add Dependabot configuration and critical-vuln gate (#81)
Co-authored-by: dependabot-rollout-bot <devops@simplify9.com>
1 parent 8e3527e commit 8aebbb4

3 files changed

Lines changed: 135 additions & 0 deletions

File tree

.github/dependabot.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Dependabot config for .NET / NuGet API repos.
2+
# main is replaced by the rollout script with `develop` (if the
3+
# repo has that branch) or the repo's actual default branch otherwise.
4+
version: 2
5+
updates:
6+
- package-ecosystem: "nuget"
7+
directory: "/"
8+
target-branch: "main"
9+
schedule:
10+
interval: "weekly"
11+
day: "monday"
12+
time: "06:00"
13+
timezone: "Asia/Amman"
14+
open-pull-requests-limit: 10
15+
groups:
16+
nuget-minor-patch:
17+
update-types: ["minor", "patch"]
18+
labels:
19+
- "dependencies"
20+
- "nuget"
21+
22+
- package-ecosystem: "github-actions"
23+
directory: "/"
24+
target-branch: "main"
25+
schedule:
26+
interval: "weekly"
27+
day: "monday"
28+
time: "06:00"
29+
timezone: "Asia/Amman"
30+
open-pull-requests-limit: 5
31+
groups:
32+
actions-minor-patch:
33+
update-types: ["minor", "patch"]
34+
labels:
35+
- "dependencies"
36+
- "github-actions"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# =============================================================================
2+
# Critical Dependabot Vulnerability Check — Caller template
3+
# =============================================================================
4+
# USAGE:
5+
# Copy this file to your repo at .github/workflows/critical-vuln-check.yml.
6+
# No REPLACE values needed — this template requires no customization.
7+
#
8+
# WHAT IT DOES:
9+
# Runs on every PR targeting main or develop. Fails if the repository has
10+
# any open CRITICAL-severity Dependabot alert.
11+
#
12+
# Enforcement differs by target branch via each repo's OWN branch
13+
# protection settings (not by anything in this file):
14+
# - On `main`: mark this check REQUIRED in branch protection — merge
15+
# is physically blocked while a critical alert is open.
16+
# - On `develop`: leave this check NOT required — it still shows as a
17+
# failing/red check (a visible warning) without blocking
18+
# the merge.
19+
# =============================================================================
20+
name: Critical Vulnerability Check
21+
run-name: vuln-check-${{ github.event.pull_request.number }}
22+
23+
on:
24+
pull_request:
25+
branches: [main, develop]
26+
27+
# critical-vuln-gate.yml's own job requests these two scopes -- a caller can
28+
# only narrow permissions for a nested reusable-workflow job, never widen
29+
# them, so these must be granted here or the whole file fails to parse.
30+
permissions:
31+
contents: write
32+
security-events: read
33+
34+
jobs:
35+
vuln-gate:
36+
uses: simplify9/.github/.github/workflows/critical-vuln-gate.yml@main
37+
secrets:
38+
dependabot-alerts-token: ${{ secrets.DEPENDABOT_ALERTS_TOKEN }}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# =============================================================================
2+
# Dependabot Auto-Merge — Caller template
3+
# =============================================================================
4+
# USAGE:
5+
# Copy this file to your repo at .github/workflows/dependabot-auto-merge.yml.
6+
# No REPLACE values needed.
7+
#
8+
# WHAT IT DOES:
9+
# Auto-merges a Dependabot PR ONLY when ALL of the following hold:
10+
# - The PR author is dependabot[bot]
11+
# - The update is a semver PATCH bump (never minor/major)
12+
# - The ecosystem is npm, nuget, pub, bundler, or github-actions
13+
# (NEVER docker — base image bumps always need manual review)
14+
# - This repo currently has no open critical Dependabot alert (re-checked
15+
# here explicitly — see workflow-templates/critical-vuln-check.yml's
16+
# header for why this can't just `needs:` that file's job)
17+
# "Auto-merge" here means GitHub's native auto-merge feature: it still
18+
# waits for the repo's actual required status checks (build/test) to pass
19+
# before merging — this workflow does not bypass those.
20+
# =============================================================================
21+
name: Dependabot Auto-Merge
22+
23+
on:
24+
pull_request:
25+
branches: [main, develop]
26+
27+
permissions:
28+
pull-requests: write
29+
contents: write
30+
security-events: read
31+
32+
jobs:
33+
vuln-gate:
34+
if: ${{ github.actor == 'dependabot[bot]' }}
35+
uses: simplify9/.github/.github/workflows/critical-vuln-gate.yml@main
36+
secrets:
37+
dependabot-alerts-token: ${{ secrets.DEPENDABOT_ALERTS_TOKEN }}
38+
39+
auto-merge:
40+
needs: vuln-gate
41+
if: ${{ github.actor == 'dependabot[bot]' }}
42+
runs-on: ubuntu-latest
43+
timeout-minutes: 5
44+
steps:
45+
- name: Fetch Dependabot metadata
46+
id: metadata
47+
uses: dependabot/fetch-metadata@v2
48+
with:
49+
github-token: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Enable auto-merge for eligible patch bumps
52+
if: |
53+
steps.metadata.outputs.update-type == 'version-update:semver-patch' &&
54+
contains(fromJSON('["npm_and_yarn", "nuget", "pub", "bundler", "github_actions"]'), steps.metadata.outputs.package-ecosystem)
55+
env:
56+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
PR_URL: ${{ github.event.pull_request.html_url }}
58+
run: |
59+
set -euo pipefail
60+
echo "::notice title=🤖 [AUTO-MERGE] Enabling auto-merge::${PR_URL} — patch-level ${{ steps.metadata.outputs.package-ecosystem }} bump, vuln gate passed"
61+
gh pr merge --auto --squash "$PR_URL"

0 commit comments

Comments
 (0)