-
Notifications
You must be signed in to change notification settings - Fork 126
98 lines (98 loc) · 4.09 KB
/
genai-commander.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: genai commander
on:
issue_comment:
types: [created]
env:
# Configure default GenAIScript models
# using Ollama's models
GENAISCRIPT_DEFAULT_MODEL: ollama:qwen2.5-coder:7b
GENAISCRIPT_DEFAULT_SMALL_MODEL: ollama:qwen2.5-coder:1.5b
GENAISCRIPT_DEFAULT_VISION_MODEL: ollama:llama3.2-vision:11b
jobs:
pr_commented:
# must be PR and have a comment starting with /genai
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/genai ') }}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
# only allow PRs from the same repository
- name: Check if PR is from the same repository
id: check_pr
uses: actions/github-script@v7
with:
script: |
const { owner, repo, number } = context.issue;
const pr = await github.rest.pulls.get({ owner, repo, pull_number: number });
if(pr.data.head.repo.full_name !== `${owner}/${repo}`)
throw new Error("pull request is not from the same repository");
#
# Resolve the PR sha and ref
#
- name: resolve pr sha
id: sha
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { owner, repo, number } = context.issue;
const pr = await github.rest.pulls.get({ owner, repo, pull_number: number, });
const res = { sha: pr.data.head.sha, ref: pr.data.head.ref }
console.log(res)
return JSON.stringify(res)
#
# Checkout both main and PR branches
#
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: diff PR branch
run: git diff origin/main...origin/${{ fromJSON(steps.sha.outputs.result).ref }}
- name: diff PR commit
run: git diff origin/main...${{ fromJSON(steps.sha.outputs.result).sha }}
- name: checkout PR commit
run: git checkout ${{ fromJSON(steps.sha.outputs.result).sha }}
- name: diff main
run: git diff origin/main
#
# Setup and build project
#
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: yarn
- name: install dependencies
run: yarn install --frozen-lockfile
- name: compile
run: yarn compile
#
# Start Ollama in a docker container
#
- name: start ollama
run: yarn ollama:start
# Execute the /genai <command> found in the comment
#
- name: genaiscript pr-describe
if: contains(github.event.comment.body, '/genai describe')
run: node packages/cli/built/genaiscript.cjs run pr-describe --out ./temp/genai/pr-describe -prd --out-trace $GITHUB_STEP_SUMMARY
env:
GITHUB_ISSUE: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: genaiscript pr-review
if: contains(github.event.comment.body, '/genai review')
run: node packages/cli/built/genaiscript.cjs run pr-review --out ./temp/genai/pr-review -prc --out-trace $GITHUB_STEP_SUMMARY
env:
GITHUB_ISSUE: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_COMMIT_SHA: ${{ fromJSON(steps.sha.outputs.result).sha }}
#
# Archive the results
#
- name: Archive genai results
if: always()
uses: actions/upload-artifact@v4
with:
name: genai-results
path: ./temp/genai/**