Add an AI triage assistant #17
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Triage: Apply Labels" | |
on: | |
pull_request: | |
types: [reopened, synchronize, opened] | |
# issues: | |
# types: [opened, edited] | |
workflow_dispatch: | |
inputs: | |
issue_number: | |
description: 'Issue number to triage' | |
required: true | |
type: number | |
permissions: | |
contents: read | |
issues: read | |
models: read | |
jobs: | |
triage-issue: | |
name: Apply Labels | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Get Issue Data | |
id: issue-data | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const issue_number = | |
github.event_name === 'workflow_dispatch' ? context.payload.inputs.issue_number : | |
github.event_name === 'issues' ? github.event.issue.number : | |
'29634'; | |
const issue = await github.rest.issues.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue_number | |
}); | |
const data = { | |
title: issue.data.title, | |
body: issue.data.body, | |
number: issue.data.number | |
}; | |
const fs = require('fs'); | |
fs.writeFileSync('issue.json', JSON.stringify(data, null, 2)); | |
return data; | |
- name: Create Prompt | |
id: create-prompt | |
shell: pwsh | |
run: | | |
$issue = Get-Content -Raw "issue.json" | ConvertFrom-Json | |
$number = $issue.number | |
$title = $issue.title | |
$body = $issue.body | |
Set-Content -Path "prompt.md" -Value @" | |
A new issue has arrived, please triage and apply the appropriate labels. | |
The issue is as follows: | |
The issue number is: | |
#$number | |
The title is: | |
$title | |
The body is: | |
$body | |
"@ | |
- name: Log Prompts | |
run: | | |
echo "::group::System Prompt" | |
cat .github/prompts/apply-label.prompt.md | |
echo "::endgroup::" | |
echo "::group::User Prompt" | |
cat prompt.md | |
echo "::endgroup::" | |
- name: Load System Prompt | |
id: load-system-prompt | |
shell: pwsh | |
run: | | |
"system_prompt=$((Get-Content -Raw ".github/prompts/apply-label.prompt.md") | ConvertTo-Json)" >> $env:GITHUB_OUTPUT | |
"prompt=$((Get-Content -Raw "prompt.md") | ConvertTo-Json)" >> $env:GITHUB_OUTPUT | |
- name: Run AI Inference | |
id: inference | |
uses: actions/ai-inference@v1 | |
with: | |
prompt: ${{ steps.load-system-prompt.outputs.prompt }} | |
system-prompt: ${{ steps.load-system-prompt.outputs.system_prompt }} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Log AI Analysis | |
shell: pwsh | |
run: | | |
${{ steps.inference.outputs.response }} |