mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-08-26 03:39:40 +00:00
Compare commits
11 Commits
DATA-energ
...
7e2c3136cf
Author | SHA1 | Date | |
---|---|---|---|
7e2c3136cf | |||
61348aa351 | |||
dea942f11e | |||
d62e620828 | |||
f0556813ac | |||
6d2252a403 | |||
8d265c9105 | |||
a4095c837b | |||
65d4a56135 | |||
fffa27b6ee | |||
12579fcd6e |
64
.github/workflows/pr-description.yml
vendored
Normal file
64
.github/workflows/pr-description.yml
vendored
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
name: 🤖 AI PR Description Commenter (100% Safe with jq)
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, edited]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
generate-description:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install GitHub CLI and jq
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install gh jq -y
|
||||||
|
|
||||||
|
- name: Fetch PR Commits
|
||||||
|
id: fetch_commits
|
||||||
|
run: |
|
||||||
|
COMMITS=$(gh pr view ${{ github.event.pull_request.number }} --json commits --jq '.commits[].message' | sed 's/^/- /')
|
||||||
|
echo "commits<<EOF" >> $GITHUB_ENV
|
||||||
|
echo "$COMMITS" >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}
|
||||||
|
|
||||||
|
- name: Generate PR Description with OpenAI (Safe JSON with jq)
|
||||||
|
run: |
|
||||||
|
REQUEST_BODY=$(jq -n \
|
||||||
|
--arg model "gpt-4o" \
|
||||||
|
--arg content "Given the following commit messages:\n\n${commits}\n\nGenerate a clear and professional pull request description." \
|
||||||
|
'{
|
||||||
|
model: $model,
|
||||||
|
messages: [{ role: "user", content: $content }]
|
||||||
|
}'
|
||||||
|
)
|
||||||
|
|
||||||
|
RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \
|
||||||
|
-H "Authorization: Bearer $OPENAI_API_KEY" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$REQUEST_BODY")
|
||||||
|
|
||||||
|
DESCRIPTION=$(echo "$RESPONSE" | jq -r '.choices[0].message.content')
|
||||||
|
|
||||||
|
echo "---------- OpenAI Raw Response ----------"
|
||||||
|
echo "$RESPONSE"
|
||||||
|
echo "---------- Extracted Description ----------"
|
||||||
|
echo "$DESCRIPTION"
|
||||||
|
|
||||||
|
echo "description<<EOF" >> $GITHUB_ENV
|
||||||
|
echo "$DESCRIPTION" >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
env:
|
||||||
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
|
commits: ${{ env.commits }}
|
||||||
|
|
||||||
|
- name: Post AI Generated Description as Comment
|
||||||
|
run: |
|
||||||
|
gh pr comment ${{ github.event.pull_request.number }} --body "${{ env.description }}"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}
|
@ -1,7 +1,7 @@
|
|||||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import nodemailer from 'nodemailer';
|
import * as nodemailer from 'nodemailer';
|
||||||
import Mail from 'nodemailer/lib/mailer';
|
import Mail from 'nodemailer/lib/mailer';
|
||||||
import { BatchEmailData } from './batch-email.interface';
|
import { BatchEmailData } from './batch-email.interface';
|
||||||
import { SingleEmailData } from './single-email.interface';
|
import { SingleEmailData } from './single-email.interface';
|
||||||
|
Reference in New Issue
Block a user