Pull2Press is a tool that converts GitHub pull requests into publishable content. It leverages the GitHub API to fetch pull request data and uses OpenAI's API to transform technical changes into readable, structured content.
- GitHub pull request fetching and analysis
- AI-powered content generation from code changes
- Customizable output formats
- Easy-to-use web interface
- Node.js (v16 or higher)
- npm or yarn
- GitHub account with personal access token
- OpenAI API key
-
Clone the repository:
git clone https://github.com/yourusername/pull2press.git cd pull2press
-
Install dependencies:
npm install # or yarn install
-
Create a
.env
file in the root directory with the following variables:GITHUB_TOKEN=your_github_personal_access_token OPENAI_API_KEY=your_openai_api_key NEXT_PUBLIC_BASE_URL=http://localhost:3000
-
Start the development server:
npm run dev # or yarn dev
-
Open http://localhost:3000 in your browser.
Pull2Press uses the GitHub REST API to:
- Authenticate using your personal access token
- Fetch pull request details including:
- Title, description, and author
- Files changed
- Commit messages
- Code diffs
The fetching process follows these steps:
- Initialize the Octokit client with your GitHub token
- Request pull request data using the repository owner, repo name, and PR number
- Process the response to extract relevant information
- Store the structured data for further processing
Example of GitHub API fetch operation:
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
const { data: pullRequest } = await octokit.rest.pulls.get({
owner,
repo,
pull_number: prNumber,
});
const { data: pullRequestFiles } = await octokit.rest.pulls.listFiles({
owner,
repo,
pull_number: prNumber,
});
Pull2Press leverages OpenAI's API to:
- Analyze the content of the pull request
- Generate human-readable summaries of code changes
- Create structured content based on the technical changes
The OpenAI processing pipeline:
- Prepare a prompt containing pull request metadata and code diffs
- Send the prompt to OpenAI's API with specific parameters (model, temperature, etc.)
- Process the response to generate the final content
- Format the content according to user preferences
Example of OpenAI API interaction:
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
const response = await openai.chat.completions.create({
model: "gpt-4",
messages: [
{ role: "system", content: systemPrompt },
{ role: "user", content: userPrompt }
],
temperature: 0.7,
});
const generatedContent = response.choices[0].message.content;
Pull2Press supports local Large Language Models through Ollama for development and testing:
- When running in development mode, the application will attempt to use Ollama first
- If Ollama is not available, it falls back to OpenAI
- In production environments, OpenAI is used by default
The Ollama processing pipeline:
- Check if Ollama is available at the specified endpoint
- Use the same prompt structure as the OpenAI implementation
- Send requests to the local Ollama server
- Process and format the response the same way as with OpenAI
Example of Ollama API interaction:
const response = await fetch(`${OLLAMA_API_URL}/api/chat`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: DEFAULT_MODEL,
messages: [
{ role: "system", content: systemPrompt },
{ role: "user", content: userPrompt }
],
options: {
temperature: 0.7,
},
stream: false,
}),
});
To maintain consistency and avoid duplication, Pull2Press uses shared prompt utilities:
- Common data structures and interfaces are defined in a central location
- System prompts are standardized for all LLM providers
- User prompt construction follows a consistent template
Example of shared prompt utilities:
// Shared system prompt
export const getSystemPrompt = (): string => {
return `You are an expert technical writer and software engineer...`;
};
// Shared user prompt builder
export const buildUserPrompt = (prData: PullRequestData): string => {
return `Write a detailed technical blog post about...`;
};
- Navigate to the web interface
- Enter the GitHub repository owner, name, and pull request number
- Select your desired output format
- Click "Generate" to create your content
- Review, edit, and download the generated content
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.