Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
20 changes: 20 additions & 0 deletions .github/workflows/dependabot-auto-approve.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Dependabot auto-approve
on: pull_request

permissions:
pull-requests: write

jobs:
get-metadata:
uses: ./.github/workflows/dependabot-metadata.yml

dependabot:
runs-on: ubuntu-latest
needs: get-metadata
steps:
- name: Approve a PR
if: needs.get-metadata.outputs.update-type == 'version-update:semver-patch'
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/dependabot-auto-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Dependabot auto-label
on: pull_request

permissions:
pull-requests: write
issues: write

jobs:
get-metadata:
uses: ./.github/workflows/dependabot-metadata.yml

dependabot:
runs-on: ubuntu-latest
needs: get-metadata
steps:
- name: Add a label for all production dependencies
if: needs.get-metadata.outputs.dependency-type == 'direct:production'
run: gh pr edit "$PR_URL" --add-label "dep:production"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add a label for all development dependencies
if: needs.get-metadata.outputs.dependency-type == 'direct:development'
run: gh pr edit "$PR_URL" --add-label "dep:development"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add a label for all indirect dependencies
if: needs.get-metadata.outputs.dependency-type == 'indirect'
run: gh pr edit "$PR_URL" --add-label "dep:indirect"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
get-metadata:
uses: ./.github/workflows/dependabot-metadata.yml

dependabot:
runs-on: ubuntu-latest
needs: get-metadata
steps:
- name: Enable auto-merge for Dependabot PRs
if: needs.get-metadata.outputs.update-type == 'version-update:semver-patch'
Comment on lines +16 to +17
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

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

Auto-merging based solely on patch version updates may be risky. Consider adding additional conditions like successful CI checks or specific dependency allowlists to prevent potentially breaking changes from being automatically merged.

Suggested change
- name: Enable auto-merge for Dependabot PRs
if: needs.get-metadata.outputs.update-type == 'version-update:semver-patch'
- name: Check dependency allowlist
id: allowlist
run: |
ALLOWLIST="lodash,react,express"
DEPENDENCY="${{ needs.get-metadata.outputs.dependency-name }}"
if [[ ",$ALLOWLIST," == *",$DEPENDENCY,"* ]]; then
echo "allowed=true" >> $GITHUB_OUTPUT
else
echo "allowed=false" >> $GITHUB_OUTPUT
fi
- name: Enable auto-merge for Dependabot PRs
if: needs.get-metadata.outputs.update-type == 'version-update:semver-patch' && steps.allowlist.outputs.allowed == 'true' && github.event.pull_request.mergeable_state == 'clean'

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@uniqueck, PRs can't be merge without a success CI build anyway, right?

run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63 changes: 63 additions & 0 deletions .github/workflows/dependabot-metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Get Dependabot Metadata

on:
workflow_call:
inputs:
github-token:
description: 'GitHub token for authentication'
required: false
type: string
default: ${{ github.token }}
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

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

The default value uses ${{ github.token }} which is deprecated. Use ${{ github.token }} or better yet, remove the default and make the token required, or use ${{ secrets.GITHUB_TOKEN }} as the default.

Suggested change
default: ${{ github.token }}
default: ${{ secrets.GITHUB_TOKEN }}

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds reasonable to me

outputs:
dependency-names:
description: 'Dependency names from metadata'
value: ${{ jobs.metadata.outputs.dependency-names }}
dependency-type:
description: 'Dependency type from metadata'
value: ${{ jobs.metadata.outputs.dependency-type }}
update-type:
description: 'Update type from metadata'
value: ${{ jobs.metadata.outputs.update-type }}
package-ecosystem:
description: 'Package ecosystem from metadata'
value: ${{ jobs.metadata.outputs.package-ecosystem }}
target-branch:
description: 'Target branch from metadata'
value: ${{ jobs.metadata.outputs.target-branch }}
previous-version:
description: 'Previous version from metadata'
value: ${{ jobs.metadata.outputs.previous-version }}
new-version:
description: 'New version from metadata'
value: ${{ jobs.metadata.outputs.new-version }}
alert-state:
description: 'Alert state from metadata'
value: ${{ jobs.metadata.outputs.alert-state }}
ghsa-id:
description: 'GHSA ID from metadata'
value: ${{ jobs.metadata.outputs.ghsa-id }}
cvss:
description: 'CVSS score from metadata'
value: ${{ jobs.metadata.outputs.cvss }}

jobs:
metadata:
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'dependabot[bot]'
outputs:
dependency-names: ${{ steps.metadata.outputs.dependency-names }}
dependency-type: ${{ steps.metadata.outputs.dependency-type }}
update-type: ${{ steps.metadata.outputs.update-type }}
package-ecosystem: ${{ steps.metadata.outputs.package-ecosystem }}
target-branch: ${{ steps.metadata.outputs.target-branch }}
previous-version: ${{ steps.metadata.outputs.previous-version }}
new-version: ${{ steps.metadata.outputs.new-version }}
alert-state: ${{ steps.metadata.outputs.alert-state }}
ghsa-id: ${{ steps.metadata.outputs.ghsa-id }}
cvss: ${{ steps.metadata.outputs.cvss }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: ${{ inputs.github-token }}