Skip to content

Commit d2b295a

Browse files
authored
Merge pull request #206 from GizzZmo/chore/dependabot-metadata-labels
chore(ci): configure Dependabot metadata labels
2 parents b8624ae + 5383bbd commit d2b295a

3 files changed

Lines changed: 75 additions & 5 deletions

File tree

.github/WORKFLOWS.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ All workflows have been enhanced with:
200200

201201
- Automatic PR creation for updates
202202
- Weekly schedule to minimize noise
203-
- Labels: `dependencies`, `automated`
203+
- Labels: `dependencies`, `npm` / `github-actions`, `automated`
204204
- Auto-reviewers assigned
205205
- **Grouped updates** (noise reduction):
206206
- `production-dependencies` — minor/patch production deps
@@ -217,16 +217,26 @@ All workflows have been enhanced with:
217217

218218
**Triggers:** Pull Request events from Dependabot
219219

220-
**Purpose:** Automatically merge safe dependency updates
220+
**Purpose:** Automatically merge safe dependency updates and apply metadata labels
221221

222222
**Jobs:**
223223

224224
- **Auto-merge**:
225-
- ✅ Fetch Dependabot metadata
225+
- ✅ Fetch Dependabot metadata (`dependabot/fetch-metadata@v2`)
226+
-**Ensure metadata labels exist** (`semver-major`, `semver-minor`, `semver-patch`, `production`, `development`, `npm`, `github-actions`)
227+
-**Apply metadata labels** based on update-type, dependency-type, and package-ecosystem
226228
- ✅ Check update type (major/minor/patch)
227229
- ✅ Auto-approve minor and patch updates
228230
- ✅ Enable auto-merge for safe updates
229-
- ✅ Comment on major updates requiring manual review
231+
- ✅ Comment on major updates requiring manual review (with `semver-major` label)
232+
233+
**Metadata labels applied:**
234+
235+
| Label | Source |
236+
|-------|--------|
237+
| `semver-major` / `semver-minor` / `semver-patch` | `update-type` |
238+
| `production` / `development` | `dependency-type` |
239+
| `npm` / `github-actions` | `package-ecosystem` |
230240

231241
**Safety:** Only auto-merges minor and patch updates
232242

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ updates:
1212
- 'GizzZmo'
1313
labels:
1414
- 'dependencies'
15+
- 'npm'
1516
- 'automated'
1617
commit-message:
1718
prefix: 'chore(deps):'

.github/workflows/auto-merge-dependabot.yml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
permissions:
88
contents: write
99
pull-requests: write
10+
issues: write
1011

1112
jobs:
1213
auto-merge:
@@ -21,6 +22,64 @@ jobs:
2122
with:
2223
github-token: '${{ secrets.GITHUB_TOKEN }}'
2324

25+
- name: Ensure metadata labels exist
26+
run: |
27+
# Create SemVer + dependency-type labels if missing (idempotent)
28+
declare -A LABELS=(
29+
["semver-major"]="Major version bump — requires manual review"
30+
["semver-minor"]="Minor version bump"
31+
["semver-patch"]="Patch version bump"
32+
["production"]="Production / runtime dependency"
33+
["development"]="Development / tooling dependency"
34+
["npm"]="npm package ecosystem"
35+
["github-actions"]="GitHub Actions ecosystem"
36+
)
37+
for name in "${!LABELS[@]}"; do
38+
gh label create "$name" \
39+
--description "${LABELS[$name]}" \
40+
--color "0366d6" \
41+
--force 2>/dev/null || true
42+
done
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Apply Dependabot metadata labels
47+
run: |
48+
PR_URL="${{ github.event.pull_request.html_url }}"
49+
LABELS=()
50+
51+
# SemVer labels from update-type
52+
case "${{ steps.metadata.outputs.update-type }}" in
53+
version-update:semver-major) LABELS+=("semver-major") ;;
54+
version-update:semver-minor) LABELS+=("semver-minor") ;;
55+
version-update:semver-patch) LABELS+=("semver-patch") ;;
56+
esac
57+
58+
# Dependency type (direct:production / direct:development / indirect)
59+
DEP_TYPE="${{ steps.metadata.outputs.dependency-type }}"
60+
if [[ "$DEP_TYPE" == *"production"* ]]; then
61+
LABELS+=("production")
62+
elif [[ "$DEP_TYPE" == *"development"* ]]; then
63+
LABELS+=("development")
64+
fi
65+
66+
# Package ecosystem
67+
case "${{ steps.metadata.outputs.package-ecosystem }}" in
68+
npm) LABELS+=("npm") ;;
69+
github_actions) LABELS+=("github-actions") ;;
70+
esac
71+
72+
# Apply any collected labels
73+
if [ ${#LABELS[@]} -gt 0 ]; then
74+
LABEL_ARGS=$(printf -- '--add-label %s ' "${LABELS[@]}")
75+
gh pr edit "$PR_URL" $LABEL_ARGS
76+
echo "Applied labels: ${LABELS[*]}"
77+
else
78+
echo "No additional metadata labels to apply"
79+
fi
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
2483
- name: Check if safe to auto-merge
2584
id: check_safe
2685
run: |
@@ -55,5 +114,5 @@ jobs:
55114
issue_number: context.issue.number,
56115
owner: context.repo.owner,
57116
repo: context.repo.repo,
58-
body: '⚠️ **Major version update detected!** Please review this PR manually before merging.'
117+
body: '⚠️ **Major version update detected!** Please review this PR manually before merging.\n\nLabel `semver-major` has been applied for triage.'
59118
})

0 commit comments

Comments
 (0)