Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions .github/workflows/issue-formatter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Format Issue with OpenAI

on:
issues:
types: [opened]

permissions:
issues: write

jobs:
format-issue:
runs-on: ubuntu-latest
steps:
- name: Rewrite issue body
id: body
uses: actions/github-script@v9
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
with:
script: |
const issue = context.payload.issue;

const response = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`
},
body: JSON.stringify({
model: 'gpt-4o-mini',
messages: [{
role: 'user',
content: `Rewrite this GitHub issue body using the exact format below. Keep it short, crisp and easy to understand. Do NOT add any information that wasn't in the original. Output ONLY the formatted markdown, nothing else.

Format:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is just one issue with this and it is that no matter if the issue is a feature/enhancement/bug issue, it fits all into the feature template. this is not that big of a problem but if there is a solution for this, then maybe we consider that? or we can merge this for now and later on do enhancements accordingly

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that crossed my mind in past, i was thinking to make kick off this only after tag and then we can be consious of what tag we put. But for now since this is first version we can keep it as it is and then update across repos

**Is your feature request related to a problem?**
(Describe the problem in 1-2 sentences. Explain why it matters and what pain it causes.)

**Describe the solution you'd like**
(What should be done. Use bullet points if there are multiple items.)

Here is an example of a well-formatted body:

**Is your feature request related to a problem?**
We currently don't have STT (Speech-to-Text) evaluation capabilities in our platform. NGOs need a way to evaluate transcription quality by comparing model outputs against ground truth.

**Describe the solution you'd like**
Integrate STT evaluation into the platform. We've already benchmarked few providers so for adding scaffolding for STT evaluation we can start with Gemini and use batch API

Original issue title: ${issue.title}
Original issue body:
${issue.body || '(empty)'}`
}]
})
});

const data = await response.json();

if (!data.choices || !data.choices[0]) {
core.setFailed(`OpenAI API error: ${JSON.stringify(data)}`);
return;
}

return data.choices[0].message.content;

- name: Rewrite issue title
id: title
uses: actions/github-script@v9
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
with:
script: |
const formattedBody = ${{ steps.body.outputs.result }};

const response = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`
},
body: JSON.stringify({
model: 'gpt-4o-mini',
messages: [{
role: 'user',
content: `Based on the issue body below, generate a short title in this exact format:
"Module Name: 4-5 word summary"

Examples:
- Evaluation: Automated metrics for STT
- Evaluation: Refactoring CRON
- Evaluation: Fix score format

Output ONLY the title, nothing else.

Issue body:
${formattedBody}`
}]
})
});

const data = await response.json();

if (!data.choices || !data.choices[0]) {
core.setFailed(`OpenAI API error: ${JSON.stringify(data)}`);
return;
}

return data.choices[0].message.content.replace(/^["']|["']$/g, '');

- name: Update issue
uses: actions/github-script@v9
with:
script: |
const formattedBody = ${{ steps.body.outputs.result }};
const formattedTitle = ${{ steps.title.outputs.result }};
const original = context.payload.issue.body || '(empty)';

await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
title: formattedTitle,
body: `${formattedBody}\n\n<details><summary>Original issue</summary>\n\n${original}\n\n</details>`
});