|
7 | 7 | permissions: |
8 | 8 | contents: write |
9 | 9 | pull-requests: write |
| 10 | + issues: write |
10 | 11 |
|
11 | 12 | jobs: |
12 | 13 | auto-merge: |
|
21 | 22 | with: |
22 | 23 | github-token: '${{ secrets.GITHUB_TOKEN }}' |
23 | 24 |
|
| 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 | + |
24 | 83 | - name: Check if safe to auto-merge |
25 | 84 | id: check_safe |
26 | 85 | run: | |
|
55 | 114 | issue_number: context.issue.number, |
56 | 115 | owner: context.repo.owner, |
57 | 116 | 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.' |
59 | 118 | }) |
0 commit comments