Repository navigation
bot detection #20
Workflow file for this run
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
| name: Bot Proxy Gatekeeper | |
| on: | |
| pull_request: | |
| types: [opened, edited, synchronize, reopened] | |
| pull_request_review: | |
| types: [submitted, edited, dismissed] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| issues: write | |
| concurrency: | |
| group: gatekeeper-${{ github.event.pull_request.number || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| enforce-human-review: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Analyze Authorship and Approvals | |
| id: check | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR: ${{ github.event.pull_request.number }} | |
| REPO: ${{ github.repository }} | |
| run: | | |
| # 1. Fetch PR Data | |
| PR_DATA=$(gh pr view $PR --repo $REPO --json author,body,commits,reviews) | |
| # 2. Only enforce when Devin is the PR author | |
| echo "author.login=$(gh pr view $PR --repo $REPO --json author --jq '.author.login')" | |
| echo "author.is_bot=$(gh pr view $PR --repo $REPO --json author --jq '.author.is_bot')" | |
| echo "reviews.total=$(gh pr view $PR --repo $REPO --json reviews --jq '.reviews | length')" | |
| IS_BOT_AUTHOR=$( | |
| echo "$PR_DATA" | jq ' | |
| (.author.login | endswith("[bot]")) | |
| or (.author.login == "app/devin-ai-integration") | |
| or (.author.is_bot == true) | |
| ' | |
| ) | |
| if [ "$IS_BOT_AUTHOR" != "true" ]; then | |
| echo "✅ Not a Devin-authored PR. Skipping check." | |
| exit 0 | |
| fi | |
| # 3. Filter for human approvals only | |
| COUNT=$( | |
| echo "$PR_DATA" | jq -r ' | |
| [.reviews[] | select(.state=="APPROVED" and (.author.login | endswith("[bot]") | not))] | |
| | map(.author.login) | |
| | unique | |
| | length | |
| ' | |
| ) | |
| echo "approvals.human_unique=$COUNT" | |
| # 4. Enforcement Logic | |
| if [ "$COUNT" -lt 2 ]; then | |
| echo "❌ FAIL: 2 human approvals required for Devin-authored PRs." | |
| exit 1 | |
| fi | |
| echo "✅ Security requirements satisfied." | |
| - name: Post Security Comment | |
| if: failure() | |
| continue-on-error: true | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR: ${{ github.event.pull_request.number }} | |
| run: | | |
| MSG="⚠️ **Review Required**: A **human** is required to review bot PRs. 2 different human approvals are required before this PR can be merged." | |
| gh pr comment $PR --body "$MSG" |