Skip to content

Commit

Permalink
Dependabot automerge (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesDuboisSAP authored Sep 30, 2024
1 parent b7bf39e commit 9e194ae
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ updates:
directory: '/'
schedule:
interval: weekly
time: '08:00'
time: '02:00'
timezone: 'Europe/Berlin'
open-pull-requests-limit: 5
commit-message:
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/dependabot-automerge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: dependabot merger

on:
workflow_dispatch:
schedule:
- cron: '00 03 * * Mon' # trigger every Monday at 3:00 a.m., as our dependabot is configured to raise PRs every Monday at 2:00 a.m.

env:
DEPENDABOT_GROUPS: |
production-minor-patch group
plugins group
test group
github-actions group
jobs:
review-prs:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Approve and Merge PRs
run: |
PRS=$(gh pr list --app "dependabot" --state "open" --json number,title)
PR_NUMBERS=
while IFS= read -r GROUP; do
if [[ -z "$GROUP" ]]; then
continue
fi
MATCHES=$(jq -r --arg group "$GROUP" '.[] | select(.title | contains($group)) | .number' <<< "$PRS")
echo "[DEBUG] Found PRs for group '$GROUP': '$MATCHES'"
PR_NUMBERS="$MATCHES"$'\n'"$PR_NUMBERS"
done <<< "${{ env.DEPENDABOT_GROUPS }}"
echo "[DEBUG] Approving and Merging following PRs: '$PR_NUMBERS'"
while IFS= read -r PR_NUMBER; do
if [[ -z "$PR_NUMBER" ]]; then
continue
fi
echo "[DEBUG] Approving and Merging PR #$PR_NUMBER"
gh pr merge "$PR_NUMBER" --auto --squash
gh pr review "$PR_NUMBER" --approve
done <<< "$PR_NUMBERS"
env:
GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }}

0 comments on commit 9e194ae

Please sign in to comment.