mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-21 01:56: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:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
|
@ -6,15 +7,16 @@ on:
|
||||||
- synchronize
|
- synchronize
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
jobs:
|
jobs:
|
||||||
code_review:
|
review:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Code Review
|
|
||||||
uses: freeedcom/ai-codereviewer@main
|
- name: AI Code Reviewer
|
||||||
|
uses: dankentfield/ai-code-reviewer@main
|
||||||
with:
|
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_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
OPENAI_API_MODEL: "gpt-4-1106-preview"
|
OPENAI_API_MODEL: "gpt-4o" # Optional: defaults to "gpt-4"
|
||||||
exclude: "yarn.lock,dist/**"
|
config-file: .github/config/rules.yaml
|
|
@ -42,14 +42,14 @@ jobs:
|
||||||
with:
|
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)
|
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_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
OPENAI_API_MODEL: "gpt-4" # Optional: defaults to "gpt-4"
|
OPENAI_API_MODEL: "gpt-4o" # Optional: defaults to "gpt-4o"
|
||||||
rules_file_name: "rules.yaml" # Required
|
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
|
```yaml
|
||||||
# .github/workflows/rules.yaml
|
# .github/config/rules.yaml
|
||||||
|
|
||||||
# Global rules that apply to all files/directories unless overridden
|
# Global rules that apply to all files/directories unless overridden
|
||||||
global: [
|
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 yaml_1 = __nccwpck_require__(4083);
|
||||||
const GITHUB_TOKEN = core.getInput("GITHUB_TOKEN");
|
const GITHUB_TOKEN = core.getInput("GITHUB_TOKEN");
|
||||||
const OPENAI_API_KEY = core.getInput("OPENAI_API_KEY");
|
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 octokit = new rest_1.Octokit({ auth: GITHUB_TOKEN });
|
||||||
const openai = new openai_1.default({
|
const openai = new openai_1.default({
|
||||||
apiKey: OPENAI_API_KEY,
|
apiKey: OPENAI_API_KEY,
|
||||||
|
@ -236,7 +236,7 @@ function main() {
|
||||||
}
|
}
|
||||||
const parsedDiff = (0, parse_diff_1.default)(diff);
|
const parsedDiff = (0, parse_diff_1.default)(diff);
|
||||||
const rulesFiles = core
|
const rulesFiles = core
|
||||||
.getInput("rules_file_name")
|
.getInput("config-file")
|
||||||
.trim();
|
.trim();
|
||||||
const rules = readRules(rulesFiles);
|
const rules = readRules(rulesFiles);
|
||||||
const { ignore: allIgnorePatterns = [] } = rules;
|
const { ignore: allIgnorePatterns = [] } = rules;
|
||||||
|
@ -249,8 +249,7 @@ function main() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function readRules(fileName) {
|
function readRules(fileContents) {
|
||||||
const fileContents = (0, fs_1.readFileSync)(fileName, "utf8");
|
|
||||||
const parsed = (0, yaml_1.parse)(fileContents, { mapAsMap: true });
|
const parsed = (0, yaml_1.parse)(fileContents, { mapAsMap: true });
|
||||||
// Transform the parsed Map into a plain object
|
// Transform the parsed Map into a plain object
|
||||||
const rules = {
|
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 GITHUB_TOKEN: string = core.getInput("GITHUB_TOKEN");
|
||||||
const OPENAI_API_KEY: string = core.getInput("OPENAI_API_KEY");
|
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 });
|
const octokit = new Octokit({ auth: GITHUB_TOKEN });
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ async function main() {
|
||||||
const parsedDiff = parseDiff(diff);
|
const parsedDiff = parseDiff(diff);
|
||||||
|
|
||||||
const rulesFiles = core
|
const rulesFiles = core
|
||||||
.getInput("rules_file_name")
|
.getInput("config-file")
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
const rules = readRules(rulesFiles);
|
const rules = readRules(rulesFiles);
|
||||||
|
@ -273,8 +273,7 @@ interface RulesFile {
|
||||||
ignore: Array<string>;
|
ignore: Array<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function readRules(fileName: string): RulesFile {
|
function readRules(fileContents: string): RulesFile {
|
||||||
const fileContents = readFileSync(fileName, "utf8");
|
|
||||||
const parsed = parse(fileContents, { mapAsMap: true });
|
const parsed = parse(fileContents, { mapAsMap: true });
|
||||||
|
|
||||||
// Transform the parsed Map into a plain object
|
// Transform the parsed Map into a plain object
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue