Skip to content

Commit 8e2c504

Browse files
ci: added dependabot (#27)
1 parent b7b73a0 commit 8e2c504

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

.github/dependabot.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for Rust/Cargo dependencies
4+
- package-ecosystem: "cargo"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "09:00"
10+
open-pull-requests-limit: 10
11+
commit-message:
12+
prefix: "chore(deps)"
13+
labels:
14+
- "dependencies"
15+
# Group updates by type to separate security from version updates
16+
groups:
17+
rust-security:
18+
applies-to: security-updates
19+
patterns:
20+
- "*"
21+
rust-version-updates:
22+
applies-to: version-updates
23+
patterns:
24+
- "*"
25+
26+
# Enable version updates for npm/JavaScript packages
27+
- package-ecosystem: "npm"
28+
directory: "/"
29+
schedule:
30+
interval: "weekly"
31+
day: "monday"
32+
time: "09:00"
33+
open-pull-requests-limit: 10
34+
commit-message:
35+
prefix: "chore(deps)"
36+
labels:
37+
- "dependencies"
38+
# Group updates by type to separate security from version updates
39+
groups:
40+
npm-security:
41+
applies-to: security-updates
42+
patterns:
43+
- "*"
44+
npm-version-updates:
45+
applies-to: version-updates
46+
patterns:
47+
- "*"
48+
49+
# Enable version updates for GitHub Actions
50+
- package-ecosystem: "github-actions"
51+
directory: "/"
52+
schedule:
53+
interval: "weekly"
54+
day: "monday"
55+
time: "09:00"
56+
open-pull-requests-limit: 5
57+
commit-message:
58+
prefix: "chore(deps)"
59+
labels:
60+
- "dependencies"
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Dependabot Auto-Approve
2+
3+
on: pull_request
4+
5+
permissions:
6+
pull-requests: write
7+
contents: write
8+
9+
env:
10+
CARGO_ABOUT_VERSION: 0.8.2
11+
12+
jobs:
13+
auto-approve:
14+
runs-on: ubuntu-latest
15+
if: |
16+
github.repository == 'mongodb/atlas-local-lib-js' &&
17+
github.event.pull_request.user.login == 'dependabot[bot]'
18+
steps:
19+
- name: Checkout PR
20+
uses: actions/checkout@v5
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
ref: ${{ github.event.pull_request.head.ref }}
24+
repository: ${{ github.event.pull_request.head.repo.full_name }}
25+
26+
- name: Install Rust toolchain
27+
run: |
28+
rustup update stable
29+
rustup default stable
30+
31+
- name: Cache cargo tools
32+
uses: actions/cache@v4
33+
with:
34+
path: ~/.cargo/bin
35+
key: ${{ runner.os }}-cargo-tools-about-${{ env.CARGO_ABOUT_VERSION }}
36+
restore-keys: |
37+
${{ runner.os }}-cargo-tools-
38+
39+
- name: Install cargo-about
40+
run: |
41+
if ! command -v cargo-about &> /dev/null; then
42+
cargo install --locked --version ${{ env.CARGO_ABOUT_VERSION }} cargo-about
43+
fi
44+
45+
- name: Dependabot metadata
46+
id: metadata
47+
uses: dependabot/fetch-metadata@08eff52bf64351f401fb50d4972fa95b9f2c2d1b
48+
with:
49+
github-token: "${{ secrets.GITHUB_TOKEN }}"
50+
51+
- name: Update third-party licenses
52+
if: steps.metadata.outputs.package-ecosystem == 'cargo'
53+
run: |
54+
# Generate updated LICENSE-3RD-PARTY.txt
55+
cargo about generate about.hbs > LICENSE-3RD-PARTY.txt
56+
57+
# Check if there are changes to commit
58+
if ! git diff --quiet LICENSE-3RD-PARTY.txt; then
59+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
60+
git config --local user.name "github-actions[bot]"
61+
git add LICENSE-3RD-PARTY.txt
62+
git commit -m "chore(deps): update LICENSE-3RD-PARTY.txt"
63+
git push
64+
echo "Updated LICENSE-3RD-PARTY.txt"
65+
else
66+
echo "LICENSE-3RD-PARTY.txt is already up to date"
67+
fi
68+
69+
- name: Approve Dependabot PR
70+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' || contains(steps.metadata.outputs.dependency-names, 'security') || steps.metadata.outputs.package-ecosystem == 'github_actions'
71+
run: gh pr review --approve "$PR_URL"
72+
env:
73+
PR_URL: ${{ github.event.pull_request.html_url }}
74+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
76+
- name: Enable auto-merge for Dependabot PR
77+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' || contains(steps.metadata.outputs.dependency-names, 'security') || steps.metadata.outputs.package-ecosystem == 'github_actions'
78+
run: gh pr merge --auto --squash "$PR_URL"
79+
env:
80+
PR_URL: ${{ github.event.pull_request.html_url }}
81+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)