Skip to content

Commit a09cdc3

Browse files
authored
ci(dependabot): prevent python version drift & auto-orchestrate updates (#5)
* ci: derive python version from dockerfile to prevent drift Implement dynamic python-version extraction in CI workflow by parsing the Dockerfile FROM instruction. This ensures the unit test environment always matches the container runtime without manual intervention. * ci: implement automated maintenance via dependabot automerge Add a dedicated workflow to enable GitHub's native auto-merge feature for Dependabot PRs. This allows dependencies that pass CI to be merged automatically, reducing manual maintenance overhead. * meta: synchronize weekly maintenance window and grouping Align all Dependabot ecosystems (pip, docker, actions) to trigger weekly on Mondays at 05:00 UTC. Enable update grouping and rebase strategy to minimize PR noise and ensure a streamlined update cycle. * fix: address PR review feedback for CI and automerge - Add validation to Python version extraction in ci.yml - Remove unused python-version job output in ci.yml - Switch automerge trigger to pull_request_target for write permissions
1 parent a9079fe commit a09cdc3

3 files changed

Lines changed: 50 additions & 10 deletions

File tree

.github/dependabot.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ updates:
33
- package-ecosystem: "pip"
44
directory: "/"
55
schedule:
6-
interval: "monthly"
7-
open-pull-requests-limit: 1
6+
interval: "weekly"
7+
day: "monday"
8+
time: "05:00"
9+
open-pull-requests-limit: 10
10+
pull-request-branch-merge-strategy: "rebase"
811
groups:
9-
monthly-python:
12+
python-dependencies:
1013
patterns:
1114
- "*"
1215
commit-message:
@@ -15,10 +18,13 @@ updates:
1518
- package-ecosystem: "github-actions"
1619
directory: "/"
1720
schedule:
18-
interval: "monthly"
19-
open-pull-requests-limit: 1
21+
interval: "weekly"
22+
day: "monday"
23+
time: "05:00"
24+
open-pull-requests-limit: 10
25+
pull-request-branch-merge-strategy: "rebase"
2026
groups:
21-
monthly-actions:
27+
actions-dependencies:
2228
patterns:
2329
- "*"
2430
commit-message:
@@ -27,10 +33,13 @@ updates:
2733
- package-ecosystem: "docker"
2834
directory: "/"
2935
schedule:
30-
interval: "monthly"
31-
open-pull-requests-limit: 1
36+
interval: "weekly"
37+
day: "monday"
38+
time: "05:00"
39+
open-pull-requests-limit: 10
40+
pull-request-branch-merge-strategy: "rebase"
3241
groups:
33-
monthly-docker:
42+
docker-dependencies:
3443
patterns:
3544
- "*"
3645
commit-message:

.github/workflows/ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,24 @@ jobs:
1717
- name: Check out repository
1818
uses: actions/checkout@v6
1919

20+
- name: Get Python version from Dockerfile
21+
id: get-version
22+
run: |
23+
# Extract version like "3.14" from "FROM python:3.14-slim..."
24+
VERSION=$(grep -m 1 "^FROM python:" Dockerfile | sed -E 's/^FROM python:([0-9]+\.[0-9]+).*/\1/')
25+
26+
if [ -z "$VERSION" ]; then
27+
echo "Error: Could not extract Python version from Dockerfile"
28+
exit 1
29+
fi
30+
31+
echo "Extracted version: $VERSION"
32+
echo "version=$VERSION" >> $GITHUB_OUTPUT
33+
2034
- name: Set up Python
2135
uses: actions/setup-python@v6
2236
with:
23-
python-version: "3.12"
37+
python-version: ${{ steps.get-version.outputs.version }}
2438
cache: "pip"
2539

2640
- name: Install Python dependencies
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Dependabot Automerge
2+
on: pull_request_target
3+
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
8+
jobs:
9+
automerge:
10+
runs-on: ubuntu-latest
11+
if: github.actor == 'dependabot[bot]'
12+
steps:
13+
- name: Enable automerge for Dependabot PRs
14+
run: gh pr merge --auto --merge "$PR_URL"
15+
env:
16+
PR_URL: ${{ github.event.pull_request.html_url }}
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)