-
-
Notifications
You must be signed in to change notification settings - Fork 99
101 lines (91 loc) · 2.8 KB
/
reusable-ai-triage.yml
File metadata and controls
101 lines (91 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: AI Triage
on:
workflow_call:
inputs:
pr_number:
required: true
type: string
head_sha:
required: true
type: string
head_repo:
required: true
type: string
base_repo:
required: true
type: string
run_id:
required: true
type: string
pr_author:
required: true
type: string
secrets:
GEMINI_API_KEY:
required: true
APP_ID:
required: true
PRIVATE_KEY:
required: true
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- name: Generate Bot Token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- name: Checkout Reusable Workflow
uses: actions/checkout@v4
with:
repository: openwisp/openwisp-utils
ref: issues/524-ci-failure-bot # will change to master upon merge
path: trusted_scripts
- name: Checkout PR Code
uses: actions/checkout@v4
with:
repository: ${{ inputs.head_repo }}
ref: ${{ inputs.head_sha }}
path: pr_code
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install Tools
run: |
pip install google-genai==1.62.0
npm install -g repomix@0.3.5
- name: Fetch CI Logs
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
RUN_ID: ${{ inputs.run_id }}
REPO: ${{ inputs.base_repo }}
run: |
gh run view $RUN_ID --repo $REPO --log-failed > failed_logs.txt
if [ ! -s failed_logs.txt ]; then
echo "No failed logs found or inaccessible run." > failed_logs.txt
fi
- name: Pack Context
run: |
cd pr_code
repomix --include "**/*.py,**/*.js,**/*.jsx,**/*.ts,**/*.tsx,**/*.yaml,**/*.yml,**/*.sh,**/*.html,**/*.css,**/*.rst,**/*.md,**/*.lua,**/Makefile,**/Dockerfile" --style xml --output ../repo_context.xml
- name: Run AI Analysis
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
PR_AUTHOR: ${{ inputs.pr_author }}
COMMIT_SHA: ${{ inputs.head_sha }}
run: |
python trusted_scripts/.github/scripts/ai_suggest.py > solution.md
- name: Post Comment
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
PR_NUM: ${{ inputs.pr_number }}
REPO: ${{ inputs.base_repo }}
run: |
if [ ! -s solution.md ]; then
echo "AI analysis produced no output; skipping comment."
exit 0
fi
gh pr comment "$PR_NUM" --repo "$REPO" --body-file solution.md