|
| 1 | +name: PyDeequ Bot |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: [opened, reopened] |
| 6 | + pull_request_target: # Runs base branch code with secrets; safe because bot fetches diff via API, never executes PR code. NEVER add ref: to checkout. |
| 7 | + types: [opened, reopened, synchronize] |
| 8 | + issue_comment: |
| 9 | + types: [created] |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + issue_number: |
| 13 | + description: "Issue/PR number to process" |
| 14 | + required: true |
| 15 | + dry_run: |
| 16 | + description: "Dry run (no writes)" |
| 17 | + type: boolean |
| 18 | + default: true |
| 19 | + |
| 20 | +# Serialize per issue/PR to prevent duplicate comments |
| 21 | +concurrency: |
| 22 | + group: bot-${{ github.event.issue.number || github.event.pull_request.number || inputs.issue_number }} |
| 23 | + cancel-in-progress: false |
| 24 | + |
| 25 | +jobs: |
| 26 | + analyze: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + timeout-minutes: 10 |
| 29 | + if: >- |
| 30 | + (github.event_name == 'workflow_dispatch') || |
| 31 | + (github.actor != 'github-actions[bot]' && |
| 32 | + (github.event.issue.pull_request == null || github.event_name == 'pull_request_target')) |
| 33 | + permissions: |
| 34 | + contents: read |
| 35 | + id-token: write |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Checkout repository |
| 39 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 40 | + with: |
| 41 | + persist-credentials: false |
| 42 | + |
| 43 | + - name: Configure AWS credentials |
| 44 | + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 |
| 45 | + with: |
| 46 | + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} |
| 47 | + aws-region: us-east-1 |
| 48 | + |
| 49 | + - name: Set up Python |
| 50 | + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 |
| 51 | + with: |
| 52 | + python-version: "3.12" |
| 53 | + |
| 54 | + - name: Install dependencies |
| 55 | + run: pip install requests==2.33.1 boto3==1.42.94 |
| 56 | + |
| 57 | + - name: Run analysis |
| 58 | + env: |
| 59 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + GITHUB_REPOSITORY: ${{ github.repository }} |
| 61 | + ISSUE_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number || inputs.issue_number }} |
| 62 | + EVENT_TYPE: ${{ github.event_name }} |
| 63 | + EVENT_ACTION: ${{ github.event.action }} |
| 64 | + EVENT_BEFORE: ${{ github.event.before }} |
| 65 | + EVENT_AFTER: ${{ github.event.pull_request.head.sha || github.event.after }} |
| 66 | + GITHUB_ACTOR: ${{ github.actor }} |
| 67 | + KB_S3_BUCKET: ${{ secrets.KB_S3_BUCKET }} |
| 68 | + KB_S3_KEY: ${{ secrets.KB_S3_KEY }} |
| 69 | + BEDROCK_MODEL_ID: ${{ secrets.BEDROCK_MODEL_ID }} |
| 70 | + GUARDRAIL_ID: ${{ secrets.GUARDRAIL_ID }} |
| 71 | + GUARDRAIL_VERSION: ${{ secrets.GUARDRAIL_VERSION }} |
| 72 | + SM_ISSUE_CLASSIFY_PROMPT: pydeequ-bot/issue-classify-prompt |
| 73 | + SM_ISSUE_RESPOND_PROMPT: pydeequ-bot/issue-respond-prompt |
| 74 | + SM_PR_FILE_REVIEW_PROMPT: pydeequ-bot/pr-file-review-prompt |
| 75 | + SM_FOLLOWUP_PROMPT: pydeequ-bot/followup-prompt |
| 76 | + CODEBASE_SRC_DIR: pydeequ |
| 77 | + CODEBASE_FILE_EXT: .py |
| 78 | + DRY_RUN: ${{ inputs.dry_run || 'false' }} |
| 79 | + ARTIFACT_PATH: ${{ runner.temp }}/bot_result.json |
| 80 | + run: python -m issue_bot.main analyze |
| 81 | + working-directory: scripts |
| 82 | + |
| 83 | + - name: Upload artifact |
| 84 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 85 | + with: |
| 86 | + name: bot-result |
| 87 | + path: ${{ runner.temp }}/bot_result.json |
| 88 | + retention-days: 30 |
| 89 | + |
| 90 | + act: |
| 91 | + runs-on: ubuntu-latest |
| 92 | + timeout-minutes: 1 |
| 93 | + needs: analyze |
| 94 | + permissions: |
| 95 | + contents: read |
| 96 | + issues: write |
| 97 | + pull-requests: write |
| 98 | + |
| 99 | + steps: |
| 100 | + - name: Checkout repository |
| 101 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 102 | + with: |
| 103 | + persist-credentials: false |
| 104 | + |
| 105 | + - name: Set up Python |
| 106 | + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 |
| 107 | + with: |
| 108 | + python-version: "3.12" |
| 109 | + |
| 110 | + - name: Install dependencies |
| 111 | + run: pip install requests==2.33.1 boto3==1.42.94 |
| 112 | + |
| 113 | + - name: Download artifact |
| 114 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 115 | + with: |
| 116 | + name: bot-result |
| 117 | + path: ${{ runner.temp }} |
| 118 | + |
| 119 | + - name: Execute actions |
| 120 | + env: |
| 121 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 122 | + GITHUB_REPOSITORY: ${{ github.repository }} |
| 123 | + ISSUE_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number || inputs.issue_number }} |
| 124 | + EVENT_TYPE: ${{ github.event_name }} |
| 125 | + EVENT_ACTION: ${{ github.event.action }} |
| 126 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 127 | + DRY_RUN: ${{ inputs.dry_run || 'false' }} |
| 128 | + ARTIFACT_PATH: ${{ runner.temp }}/bot_result.json |
| 129 | + run: python -m issue_bot.main act |
| 130 | + working-directory: scripts |
0 commit comments