Skip to content

Find a QA who could help #221

Find a QA who could help

Find a QA who could help #221

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<<EOF" >> $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
});