From ad89254cc87cfa1298187252fa4354b121d0cfe7 Mon Sep 17 00:00:00 2001 From: "entelligence-issue-bot-testing[bot]" <175242829+entelligence-issue-bot-testing[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 18:43:59 +0000 Subject: [PATCH] Add Entelligence-AI Issue Solver --- .github/workflows/issue-solver.yml | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/issue-solver.yml diff --git a/.github/workflows/issue-solver.yml b/.github/workflows/issue-solver.yml new file mode 100644 index 00000000..9f4e120a --- /dev/null +++ b/.github/workflows/issue-solver.yml @@ -0,0 +1,72 @@ + +name: Entelligence-AI +permissions: + contents: read + issues: write +on: + issues: + types: [opened, edited] +jobs: + handle_issues: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Extract Repository and Username + id: extract-repo-info + run: | + repo_name=$(basename $GITHUB_REPOSITORY) + username=$(dirname $GITHUB_REPOSITORY | cut -d'/' -f1) + echo "REPO_NAME=$repo_name" >> $GITHUB_ENV + echo "USERNAME=$username" >> $GITHUB_ENV + + - name: Sanitize Issue Body + id: sanitize-body + run: | + sanitized_body=$(echo "${{ github.event.issue.body }}" | tr -d '\r' | tr '\n' ' ') + echo "SANITIZED_BODY=${sanitized_body}" >> $GITHUB_ENV + + - name: Debug Sanitized Body + run: | + echo "Sanitized Body: ${{ env.SANITIZED_BODY }}" + + - name: Call API + id: call-api + env: + API_URL: ${{ secrets.ENTELLIGENCE_AI_ISSUE_API }} + ISSUE_TITLE: ${{ github.event.issue.title }} + ISSUE_BODY: ${{ env.SANITIZED_BODY }} + REPO_NAME: ${{ env.REPO_NAME }} + USERNAME: ${{ env.USERNAME }} + run: | + set +e + response=$(curl -s -X POST ${{env.API_URL}} \ + -H "Content-Type: application/json" \ + -d "{\"vectorDBUrl\": \"${{env.USERNAME}}&${{env.REPO_NAME}}\", \"title\": \"${{env.ISSUE_TITLE}}\", \"summary\": \"${{env.ISSUE_BODY}}\", \"repoName\": \"${{env.USERNAME}}/${{env.REPO_NAME}}\"}") + body=$(echo "$response" | sed '$d') + echo "$response" + echo "API_RESPONSE<> $GITHUB_ENV + echo $(printf "%s" "$body" | base64) >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + set -e + + - name: Post Comment on Issue + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const issueNumber = context.issue.number; + const apiResponse = Buffer.from(process.env.API_RESPONSE, 'base64').toString('utf-8'); + + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issueNumber, + body: apiResponse + });