diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 500704a60..5fa9aef94 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -13,6 +13,7 @@ reviews: auto_title_placeholder: '@coderabbitai' review_status: true commit_status: true + fail_commit_status: true poem: true collapse_walkthrough: false sequence_diagrams: true diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d04ea2695..e93de321c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,3 +7,7 @@ updates: interval: "weekly" cooldown: default-days: 7 + groups: + github-actions: + patterns: + - "*" diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 000000000..28d297783 --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,54 @@ +--- +name: Dependabot review and auto-merge + +"on": + pull_request: + types: + - opened + - reopened + - ready_for_review + - synchronize + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +permissions: + contents: write + issues: write + pull-requests: write + +jobs: + review-and-enable-auto-merge: + if: >- + github.event.pull_request.user.login == 'dependabot[bot]' && + github.repository == 'acgetchell/CDT-plusplus' + runs-on: ubuntu-latest + steps: + - name: Request CodeRabbit review + env: + GH_TOKEN: ${{ github.token }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_URL: ${{ github.event.pull_request.html_url }} + REPOSITORY: ${{ github.repository }} + run: | + marker="" + comments="$( + gh api --paginate \ + "repos/${REPOSITORY}/issues/${PR_NUMBER}/comments" \ + --jq '.[] | select(.user.login == "github-actions[bot]") | .body' + )" + if grep -Fxq -- "$marker" <<< "$comments"; then + echo "CodeRabbit review already requested for ${PR_HEAD_SHA}." + exit 0 + fi + body="$(printf '@coderabbitai review\n\n%s' "$marker")" + gh pr comment "$PR_URL" --body "$body" + + - name: Enable auto-merge + env: + GH_TOKEN: ${{ github.token }} + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} + PR_URL: ${{ github.event.pull_request.html_url }} + run: gh pr merge --auto --squash --match-head-commit "$PR_HEAD_SHA" "$PR_URL"