dependabot merger #317
Workflow file for this run
This file contains 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
name: dependabot merger | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '13 10 * * Mon' # trigger every Monday at 10:13, as our dependabot is configured to raise PRs every Monday at 8: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: Find Dependabot PRs | |
id: find-prs | |
run: | | |
PRS=$(gh pr list --app "dependabot" --state "open" --json number,title) | |
PR_NUMBERS= | |
while IFS= read -r GROUP; do | |
MATCHES=$(jq -r --arg group "$GROUP" '.[] | select(.title | contains($group)) | .number' <<< "$PRS") | |
PR_NUMBERS="$MATCHES"$'\n'"$PR_NUMBERS" | |
done <<< "${{ env.DEPENDABOT_GROUPS }}" | |
PR_NUMBERS=$(sort --unique <<< "$PR_NUMBERS") | |
echo "PR_NUMBERS='$PR_NUMBERS'" >> $GITHUB_OUTPUT | |
env: | |
GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }} | |
- name: Approve and Merge Dependabot PRs | |
run: | | |
while IFS= read -r PR_NUMBER; do | |
if [[ -z "$PR_NUMBER" ]]; then | |
continue | |
fi | |
gh pr merge "$PR_NUMBER" --auto --squash | |
gh pr review "$PR_NUMBER" --approve | |
done <<< "$(grep --extended-regexp --ignore-case '[0-9]+' <<< '${{ steps.find-prs.outputs.PR_NUMBERS }}')" | |
env: | |
GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }} |