mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-20 17:46:47 +00:00
Use GH config dir
This commit is contained in:
parent
ed407c8427
commit
eea1319b0a
6 changed files with 21 additions and 21 deletions
0
rules.yaml → .github/config/rules.yaml
vendored
0
rules.yaml → .github/config/rules.yaml
vendored
18
.github/workflows/code_review.yml
vendored
18
.github/workflows/code_review.yml
vendored
|
@ -1,4 +1,5 @@
|
|||
name: Code Review with OpenAI
|
||||
name: AI Code Reviewer
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
|
@ -6,15 +7,16 @@ on:
|
|||
- synchronize
|
||||
permissions: write-all
|
||||
jobs:
|
||||
code_review:
|
||||
review:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v3
|
||||
- name: Code Review
|
||||
uses: freeedcom/ai-codereviewer@main
|
||||
|
||||
- name: AI Code Reviewer
|
||||
uses: dankentfield/ai-code-reviewer@main
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # The GITHUB_TOKEN is there by default so you just need to keep it like it is and not necessarily need to add it as secret as it will throw an error. [More Details](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret)
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
OPENAI_API_MODEL: "gpt-4-1106-preview"
|
||||
exclude: "yarn.lock,dist/**"
|
||||
OPENAI_API_MODEL: "gpt-4o" # Optional: defaults to "gpt-4"
|
||||
config-file: .github/config/rules.yaml
|
|
@ -42,14 +42,14 @@ jobs:
|
|||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # The GITHUB_TOKEN is there by default so you just need to keep it like it is and not necessarily need to add it as secret as it will throw an error. [More Details](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret)
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
OPENAI_API_MODEL: "gpt-4" # Optional: defaults to "gpt-4"
|
||||
rules_file_name: "rules.yaml" # Required
|
||||
OPENAI_API_MODEL: "gpt-4o" # Optional: defaults to "gpt-4o"
|
||||
config-file: .github/config/rules.yaml # Required
|
||||
```
|
||||
|
||||
4. Create a `.github/workflows/rules.yaml` file in your repository and customise the rules you would like:
|
||||
4. Create a `.github/config/rules.yaml` file in your repository and customise the rules you would like:
|
||||
|
||||
```yaml
|
||||
# .github/workflows/rules.yaml
|
||||
# .github/config/rules.yaml
|
||||
|
||||
# Global rules that apply to all files/directories unless overridden
|
||||
global: [
|
||||
|
|
7
dist/index.js
vendored
7
dist/index.js
vendored
|
@ -52,7 +52,7 @@ const minimatch_1 = __importDefault(__nccwpck_require__(2002));
|
|||
const yaml_1 = __nccwpck_require__(4083);
|
||||
const GITHUB_TOKEN = core.getInput("GITHUB_TOKEN");
|
||||
const OPENAI_API_KEY = core.getInput("OPENAI_API_KEY");
|
||||
const OPENAI_API_MODEL = core.getInput("OPENAI_API_MODEL");
|
||||
const OPENAI_API_MODEL = core.getInput("OPENAI_API_MODEL") || "gpt-4o";
|
||||
const octokit = new rest_1.Octokit({ auth: GITHUB_TOKEN });
|
||||
const openai = new openai_1.default({
|
||||
apiKey: OPENAI_API_KEY,
|
||||
|
@ -236,7 +236,7 @@ function main() {
|
|||
}
|
||||
const parsedDiff = (0, parse_diff_1.default)(diff);
|
||||
const rulesFiles = core
|
||||
.getInput("rules_file_name")
|
||||
.getInput("config-file")
|
||||
.trim();
|
||||
const rules = readRules(rulesFiles);
|
||||
const { ignore: allIgnorePatterns = [] } = rules;
|
||||
|
@ -249,8 +249,7 @@ function main() {
|
|||
}
|
||||
});
|
||||
}
|
||||
function readRules(fileName) {
|
||||
const fileContents = (0, fs_1.readFileSync)(fileName, "utf8");
|
||||
function readRules(fileContents) {
|
||||
const parsed = (0, yaml_1.parse)(fileContents, { mapAsMap: true });
|
||||
// Transform the parsed Map into a plain object
|
||||
const rules = {
|
||||
|
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -8,7 +8,7 @@ import { parse, stringify } from 'yaml'
|
|||
|
||||
const GITHUB_TOKEN: string = core.getInput("GITHUB_TOKEN");
|
||||
const OPENAI_API_KEY: string = core.getInput("OPENAI_API_KEY");
|
||||
const OPENAI_API_MODEL: string = core.getInput("OPENAI_API_MODEL");
|
||||
const OPENAI_API_MODEL: string = core.getInput("OPENAI_API_MODEL") || "gpt-4o";
|
||||
|
||||
const octokit = new Octokit({ auth: GITHUB_TOKEN });
|
||||
|
||||
|
@ -243,7 +243,7 @@ async function main() {
|
|||
const parsedDiff = parseDiff(diff);
|
||||
|
||||
const rulesFiles = core
|
||||
.getInput("rules_file_name")
|
||||
.getInput("config-file")
|
||||
.trim();
|
||||
|
||||
const rules = readRules(rulesFiles);
|
||||
|
@ -273,8 +273,7 @@ interface RulesFile {
|
|||
ignore: Array<string>;
|
||||
}
|
||||
|
||||
function readRules(fileName: string): RulesFile {
|
||||
const fileContents = readFileSync(fileName, "utf8");
|
||||
function readRules(fileContents: string): RulesFile {
|
||||
const parsed = parse(fileContents, { mapAsMap: true });
|
||||
|
||||
// Transform the parsed Map into a plain object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue