Skip to content
Merged
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
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Dependabot opens weekly update PRs. It has no auto-merge setting of its own:
# .github/workflows/dependabot-weekly-merge.yml merges the non-major PRs whose
# required test jobs and all other checks pass every Monday. Major version bumps
# are left for manual review.
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
groups:
development-dependencies:
dependency-type: development

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
83 changes: 83 additions & 0 deletions .github/workflows/dependabot-weekly-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Weekly Dependabot Merge

on:
schedule:
# Every Monday at 06:00 UTC, after Dependabot's weekly PRs have had time to run CI.
- cron: '0 6 * * 1'
workflow_dispatch:

permissions:
contents: write
pull-requests: write

concurrency:
group: dependabot-weekly-merge
cancel-in-progress: false

jobs:
merge:
runs-on: ubuntu-latest

steps:
- name: Merge green Dependabot PRs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
BASE: ${{ github.event.repository.default_branch }}
# Test jobs that must have run and passed, one per line.
REQUIRED_CHECKS: |
test
run: |
set -uo pipefail

prs=$(gh pr list --author 'app/dependabot' --base "$BASE" --state open \
--json number,title --jq '.[] | "\(.number)\t\(.title)"')

if [ -z "$prs" ]; then
echo "No open Dependabot PRs."
exit 0
fi

while IFS=$'\t' read -r number title; do
echo "::group::#$number $title"

# Skip semver-major bumps ("from 6.0.0 to 7.0.1"); review those by hand.
if [[ "$title" =~ from\ v?([0-9]+)[^\ ]*\ to\ v?([0-9]+) ]] \
&& [ "${BASH_REMATCH[1]}" != "${BASH_REMATCH[2]}" ]; then
echo "Skipping major version bump."
echo "::endgroup::"
continue
fi

# The test jobs must each have run and succeeded on this PR
# (matrix runs named "job (value)" must all have succeeded).
checks=$(gh pr view "$number" --json statusCheckRollup --jq '.statusCheckRollup')
missing=""
while IFS= read -r job; do
[ -z "$job" ] && continue
if ! jq -e --arg job "$job" \
'[.[] | select((.name // "") == $job or ((.name // "") | startswith($job + " (")))]
| length > 0 and all(.conclusion == "SUCCESS")' <<< "$checks" > /dev/null; then
missing="$missing [$job]"
fi
done <<< "$REQUIRED_CHECKS"
if [ -n "$missing" ]; then
echo "Tests not passing yet:$missing; skipping."
echo "::endgroup::"
continue
fi

# Every other check must also be green, not pending or failing.
if ! gh pr checks "$number" > /dev/null; then
echo "Another check is failing or still pending; skipping."
echo "::endgroup::"
continue
fi

if gh pr merge "$number" --squash --delete-branch; then
echo "Merged."
else
echo "::warning::Could not merge #$number (conflict, or it changes workflow files)."
fi
echo "::endgroup::"
done <<< "$prs"
Loading