Skip to content

Commit 5b08e9d

Browse files
Add Entelligence-AI Issue Solver
1 parent 485d7ff commit 5b08e9d

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/issue-solver.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
name: Entelligence-AI
3+
permissions:
4+
contents: read
5+
issues: write
6+
on:
7+
issues:
8+
types: [opened, edited]
9+
jobs:
10+
handle_issues:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js 20
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
21+
- name: Extract Repository and Username
22+
id: extract-repo-info
23+
run: |
24+
repo_name=$(basename $GITHUB_REPOSITORY)
25+
username=$(dirname $GITHUB_REPOSITORY | cut -d'/' -f1)
26+
echo "REPO_NAME=$repo_name" >> $GITHUB_ENV
27+
echo "USERNAME=$username" >> $GITHUB_ENV
28+
29+
- name: Sanitize Issue Body
30+
id: sanitize-body
31+
run: |
32+
sanitized_body=$(echo "${{ github.event.issue.body }}" | tr -d '\r' | tr '\n' ' ')
33+
echo "SANITIZED_BODY=${sanitized_body}" >> $GITHUB_ENV
34+
35+
- name: Debug Sanitized Body
36+
run: |
37+
echo "Sanitized Body: ${{ env.SANITIZED_BODY }}"
38+
39+
- name: Call API
40+
id: call-api
41+
env:
42+
API_URL: ${{ secrets.ENTELLIGENCE_AI_ISSUE_API }}
43+
ISSUE_TITLE: ${{ github.event.issue.title }}
44+
ISSUE_BODY: ${{ env.SANITIZED_BODY }}
45+
REPO_NAME: ${{ env.REPO_NAME }}
46+
USERNAME: ${{ env.USERNAME }}
47+
run: |
48+
set +e
49+
response=$(curl -s -X POST ${{env.API_URL}} \
50+
-H "Content-Type: application/json" \
51+
-d "{\"vectorDBUrl\": \"${{env.USERNAME}}&${{env.REPO_NAME}}\", \"title\": \"${{env.ISSUE_TITLE}}\", \"summary\": \"${{env.ISSUE_BODY}}\", \"repoName\": \"${{env.USERNAME}}/${{env.REPO_NAME}}\"}")
52+
body=$(echo "$response" | sed '$d')
53+
echo "$response"
54+
echo "API_RESPONSE<<EOF" >> $GITHUB_ENV
55+
echo $(printf "%s" "$body" | base64) >> $GITHUB_ENV
56+
echo "EOF" >> $GITHUB_ENV
57+
set -e
58+
59+
- name: Post Comment on Issue
60+
uses: actions/github-script@v6
61+
with:
62+
github-token: ${{ secrets.GITHUB_TOKEN }}
63+
script: |
64+
const issueNumber = context.issue.number;
65+
const apiResponse = Buffer.from(process.env.API_RESPONSE, 'base64').toString('utf-8');
66+
67+
github.rest.issues.createComment({
68+
owner: context.repo.owner,
69+
repo: context.repo.repo,
70+
issue_number: issueNumber,
71+
body: apiResponse
72+
});

0 commit comments

Comments
 (0)