Skip to content

TypeChat integration #415

TypeChat integration

TypeChat integration #415

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/**