Repository navigation
ci: let Dependabot merge patch and minor updates #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1c5272e
ci: let Dependabot merge patch and minor updates
ItsPaulAT 6c5eed4
ci: drop the up-to-date requirement from the main ruleset
ItsPaulAT aa29e6c
Refine minor version update checks for dependencies
ItsPaulAT f78cbfc
Enable strict required status checks policy
ItsPaulAT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Weekly updates of the action pins and requirements-dev.txt, 7-day cooldown; patch and minor | ||
| # updates merge on their own (dependabot-automerge.yml). | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: github-actions | ||
| directory: / | ||
| schedule: | ||
| interval: weekly | ||
| day: monday | ||
| cooldown: | ||
| default-days: 7 | ||
| commit-message: | ||
| prefix: ci | ||
| include: scope | ||
| labels: [dependencies] | ||
| open-pull-requests-limit: 5 | ||
| groups: | ||
| actions: | ||
| patterns: ["*"] | ||
| update-types: ["minor", "patch"] | ||
| actions-major: | ||
| patterns: ["*"] | ||
| update-types: ["major"] | ||
|
|
||
| - package-ecosystem: pip | ||
| directory: / | ||
| schedule: | ||
| interval: weekly | ||
| day: monday | ||
| cooldown: | ||
| default-days: 7 | ||
| commit-message: | ||
| prefix: build | ||
| include: scope | ||
| labels: [dependencies] | ||
| open-pull-requests-limit: 5 | ||
| groups: | ||
| dev-tools: | ||
| patterns: ["*"] | ||
| update-types: ["minor", "patch"] | ||
| dev-tools-major: | ||
| patterns: ["*"] | ||
| update-types: ["major"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # Approves Dependabot's patch and minor updates and turns on auto-merge (squash); GitHub merges | ||
| # once the required checks pass. Majors, 0.x minors and updates without a semver type (image | ||
| # digests) stay for a manual review. The update types come from the metadata block of | ||
| # Dependabot's commit message, the same source dependabot/fetch-metadata reads. | ||
| name: dependabot-automerge | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
|
|
||
| permissions: {} | ||
|
|
||
| concurrency: | ||
| group: dependabot-automerge-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| automerge: | ||
| name: automerge | ||
| if: >- | ||
| github.event.pull_request.user.login == 'dependabot[bot]' && | ||
| github.event.pull_request.head.repo.full_name == github.repository | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 5 | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| steps: | ||
| - name: Approve and enable auto-merge for patch and minor updates | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| REPO: ${{ github.repository }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | ||
| run: | | ||
| set -euo pipefail | ||
| commits="$(gh api "repos/$REPO/pulls/$PR_NUMBER/commits?per_page=100")" | ||
| authors="$(jq -r '[.[].author.login // "unknown"] | unique | join(",")' <<<"$commits")" | ||
| if [ "$authors" != "dependabot[bot]" ]; then | ||
| echo "::notice::Commits by $authors; left for a manual review." | ||
| exit 0 | ||
| fi | ||
| export MESSAGE | ||
| MESSAGE="$(jq -r '.[-1].commit.message' <<<"$commits")" | ||
| verdict="$(python3 - <<'PY' | ||
| import os | ||
| deps, block = [], False | ||
| for line in os.environ["MESSAGE"].splitlines(): | ||
| if line == "updated-dependencies:": | ||
| block = True | ||
| elif block and line in ("...", "---", ""): | ||
| break | ||
| elif block and line.startswith("- "): | ||
| deps.append({}) | ||
| if block and deps and ":" in line: | ||
| key, _, value = line[2:].partition(":") | ||
| deps[-1][key.strip()] = value.strip().strip("'\"") | ||
| reasons = [] | ||
| for d in deps: | ||
| kind = d.get("update-type", "") | ||
| name = d.get("dependency-name", "?") | ||
| if kind not in ("version-update:semver-patch", "version-update:semver-minor"): | ||
| reasons.append(f"{name}: {kind or 'no semver update type'}") | ||
| elif kind.endswith("minor") and ( | ||
| not d.get("dependency-version") | ||
| or d["dependency-version"].startswith("0.") | ||
| ): | ||
| reasons.append(f"{name}: minor update below 1.0 or unknown dependency version") | ||
| print("; ".join(reasons) if deps else "no update metadata") | ||
| PY | ||
| )" | ||
| if [ -n "$verdict" ]; then | ||
| echo "::notice::Left for a manual review ($verdict)." | ||
| exit 0 | ||
| fi | ||
| url="https://github.com/$REPO/pull/$PR_NUMBER" | ||
| gh pr review "$url" --approve || echo "::warning::Could not approve the pull request." | ||
| gh pr merge "$url" --auto --squash --match-head-commit "$HEAD_SHA" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.