|
1 | | -name: PyDeequ Bot |
| 1 | +name: PyDeequ Bot # load-bearing: auto-approve.yml keys on this exact name |
| 2 | +# To upgrade the engine, bump the SHA in BOTH `uses:` and `shadow_ref` below |
| 3 | +# (GitHub forbids expressions in `uses:`, so they can't share a variable). |
2 | 4 |
|
3 | 5 | on: |
4 | 6 | issues: |
5 | 7 | 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. |
| 8 | + pull_request_target: # base-branch checkout only; never add ref: (see SECURITY A1) |
7 | 9 | types: [opened, reopened, synchronize] |
8 | 10 | issue_comment: |
9 | 11 | types: [created] |
|
17 | 19 | type: boolean |
18 | 20 | default: true |
19 | 21 |
|
20 | | -# Serialize per issue/PR to prevent duplicate comments |
| 22 | +# Union of the reusable workflow's nested-job permissions; a caller must grant |
| 23 | +# these or the call fails at startup (each nested job still narrows its own set). |
| 24 | +permissions: |
| 25 | + contents: read |
| 26 | + id-token: write |
| 27 | + pull-requests: write |
| 28 | + issues: write |
| 29 | + |
| 30 | +# inputs.issue_number fallback: workflow_dispatch has no event PR/issue number. |
21 | 31 | concurrency: |
22 | 32 | group: bot-${{ github.event.issue.number || github.event.pull_request.number || inputs.issue_number }} |
23 | 33 | cancel-in-progress: false |
24 | 34 |
|
25 | 35 | jobs: |
26 | | - analyze: |
27 | | - runs-on: ubuntu-latest |
28 | | - timeout-minutes: 10 |
| 36 | + shadow: |
| 37 | + # Avoid self-triggered loops (bot's own comments) and double-reviewing a PR |
| 38 | + # from both issue_comment and pull_request_target; dispatch is always manual. |
29 | 39 | if: >- |
30 | 40 | (github.event_name == 'workflow_dispatch') || |
31 | 41 | (github.actor != 'github-actions[bot]' && |
32 | 42 | (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 |
| 43 | + uses: sudsali/shadow/.github/workflows/shadow-review.yml@54ec94e0ca8c90d9b58ff95a2a06b175a115784e |
| 44 | + with: |
| 45 | + pr_number: ${{ inputs.issue_number }} |
| 46 | + dry_run: ${{ inputs.dry_run && 'true' || 'false' }} |
| 47 | + shadow_ref: 54ec94e0ca8c90d9b58ff95a2a06b175a115784e |
| 48 | + aws_region: us-east-1 |
| 49 | + prompt_sm_prefix: pydeequ-bot |
| 50 | + secrets: |
| 51 | + AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} |
| 52 | + GUARDRAIL_ID: ${{ secrets.GUARDRAIL_ID }} |
| 53 | + GUARDRAIL_VERSION: ${{ secrets.GUARDRAIL_VERSION }} |
| 54 | + KB_S3_BUCKET: ${{ secrets.KB_S3_BUCKET }} |
| 55 | + KB_S3_KEY: ${{ secrets.KB_S3_KEY }} |
| 56 | + BEDROCK_MODEL_ID: ${{ secrets.BEDROCK_MODEL_ID }} |
| 57 | + BEDROCK_REPORTER_MODEL_ID: ${{ vars.BEDROCK_REPORTER_MODEL_ID }} |
| 58 | + BEDROCK_CRITIC_MODEL_ID: ${{ vars.BEDROCK_CRITIC_MODEL_ID }} |
| 59 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
0 commit comments