Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/labeler-dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Labeler - Dependabot

on:
pull_request:
types:
- opened
- synchronize
- reopened

Comment on lines +3 to +5
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description states the workflow (a) runs on pull_request “all event types” and (b) follows the documented dependabot/fetch-metadata pattern, but the workflow currently uses default pull_request event types and doesn’t call dependabot/fetch-metadata. Either update the workflow to match (e.g., specify types: and/or add fetch-metadata) or adjust the PR description to reflect the implemented approach.

Copilot uses AI. Check for mistakes.
# Permissions needed to label PRs and create/update labels.
# security-events: read is required for dependabot/fetch-metadata alert-lookup.
permissions:
contents: read
pull-requests: write
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github.rest.issues.* endpoints (label creation + applying labels) require the issues: write permission on GITHUB_TOKEN. With only pull-requests: write, these API calls can fail with 403 in repos where issues write isn’t implicitly granted. Add issues: write (and keep/remove pull-requests as needed).

Suggested change
pull-requests: write
pull-requests: write
issues: write

Copilot uses AI. Check for mistakes.
issues: write
security-events: read

jobs:
label-dependabot:
runs-on: ubuntu-latest
# Only run for Dependabot-authored pull requests
if: github.event.pull_request.user.login == 'dependabot[bot]'
steps:
# Fetch metadata about the dependencies being updated.
# alert-lookup: true populates ghsa-id / alert-state for security update PRs.
# Note: if GITHUB_TOKEN does not have sufficient Dependabot alert access (e.g.
# private repos or restricted org settings) you can replace secrets.GITHUB_TOKEN
# with a fine-grained PAT that has the `security_events` read permission.
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
Comment thread Fixed
Comment thread Fixed
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
alert-lookup: true

# Ensure the custom labels exist before applying them.
# `gh label create --force` is a no-op when the label already exists,
# so this step is safe to run on every PR and handles the case where
# the labels have not yet been created in the repository.
- name: Ensure labels exist
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh label create "dependabot-security-update" \
--color "e11d48" \
--description "Dependabot security update" \
--repo "${{ github.repository }}" \
--force
gh label create "dependabot-version-update" \
--color "0075ca" \
--description "Dependabot version update" \
--repo "${{ github.repository }}" \
--force

# Apply the security-update label when fetch-metadata identifies a GHSA.
- name: Label as security update
if: steps.metadata.outputs.ghsa-id != ''
run: gh pr edit "$PR_URL" --add-label "dependabot-security-update"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Apply the version-update label when no GHSA is associated with the PR.
- name: Label as version update
if: steps.metadata.outputs.ghsa-id == ''
run: gh pr edit "$PR_URL" --add-label "dependabot-version-update"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading