Skip to content

Instantly share code, notes, and snippets.

@ericksoa
Created March 21, 2023 21:39
Show Gist options
  • Select an option

  • Save ericksoa/3507e10c269e3106313a267850077a9c to your computer and use it in GitHub Desktop.

Select an option

Save ericksoa/3507e10c269e3106313a267850077a9c to your computer and use it in GitHub Desktop.
Automate the job of a programmer picking up a story
// main.ts
import { JiraClient } from './jiraClient';
import { OpenAIClient } from './openAIClient';
import { GitClient } from './gitClient';
async function main() {
// Configure your clients
const jiraClient = new JiraClient('https://your-jira-instance.atlassian.net', 'your-jira-api-token');
const openAIClient = new OpenAIClient('your-openai-api-key');
const gitClient = new GitClient('https://your-git-instance.com', 'your-git-api-token');
// Get the next Jira story
const story = await jiraClient.getNextStory();
// Generate code using OpenAI API
const code = await openAIClient.generateCode(story.summary);
// Commit code to a new branch
const branchName = `feature/${story.key}`;
await gitClient.createBranch(branchName);
await gitClient.commitCode(branchName, code);
// Create a pull request
await gitClient.createPullRequest(branchName, 'main', `Implement ${story.key}`);
console.log('Pull request created for', story.key);
}
main().catch((error) => console.error('Error:', error));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment