ENG
- Branchen
- Finanzen
Nearshore-Softwareentwicklung für den Finanzsektor – sicher, skalierbar und Compliance-gerechte Lösungen für Banking, Zahlungsverkehr und APIs.
- Einzelhandel
Softwareentwicklung für den Einzelhandel – E-Commerce, Kassensysteme, Logistik und KI-gestützte Personalisierung durch unsere Nearshore-Engineering-Teams.
- Verarbeitende Industrie
Nearshore-Softwareentwicklung für die Industrie – ERP-Systeme, IoT-Plattformen und Automatisierungstools zur Optimierung industrieller Abläufe.
- Finanzen
- Was wir tun
- Services
- Technologien
- Kooperationsmodelle
Kooperationsmodelle passend zu Ihren Bedürfnissen: Komplette Nearshoring Teams, deutschsprachige Experten vor Ort mit Nearshoring-Teams oder gemischte Teams mit unseren Partnern.
- Arbeitsweise
Durch enge Zusammenarbeit mit Ihrem Unternehmen schaffen wir maßgeschneiderte Lösungen, die auf Ihre Anforderungen abgestimmt sind und zu nachhaltigen Ergebnissen führen.
- Über uns
- Wer wir sind
Wir sind ein Full-Service Nearshoring-Anbieter für digitale Softwareprodukte, ein perfekter Partner mit deutschsprachigen Experten vor Ort, Ihre Business-Anforderungen stets im Blick
- Unser Team
Das ProductDock Team ist mit modernen Technologien und Tools vertraut und setzt seit 15 Jahren zusammen mit namhaften Firmen erfolgreiche Projekte um.
- Unsere Standorte
Wir sind ProductDock, ein Full-Service Nearshoring-Anbieter für Softwareprodukte mit Hauptsitz in Berlin und Entwicklungs-Hubs in Lissabon, Novi Sad, Banja Luka und Doboj.
- Wozu Nearshoring
Wir kombinieren Nearshore- und Fachwissen vor Ort, um Sie während Ihrer gesamten digitalen Produktreise optimal zu unterstützen. Lassen Sie uns Ihr Business gemeinsam auf das nächste digitale Level anheben.
- Wer wir sind
- Unser Leistungen
- Karriere
- Arbeiten bei ProductDock
Unser Fokus liegt auf der Förderung von Teamarbeit, Kreativität und Empowerment innerhalb unseres Teams von über 120 talentierten Tech-Experten.
- Offene Stellen
Begeistert es dich, an spannenden Projekten mitzuwirken und zu sehen, wie dein Einsatz zu erfolgreichen Ergebnissen führt? Dann bist du bei uns richtig.
- Info Guide für Kandidaten
Wie suchen wir unsere Crew-Mitglieder aus? Wir sehen dich als Teil unserer Crew und erklären gerne unseren Auswahlprozess.
- Arbeiten bei ProductDock
- Newsroom
- News
Folgen Sie unseren neuesten Updates und Veröffentlichungen, damit Sie stets über die aktuellsten Entwicklungen von ProductDock informiert sind.
- Events
Vertiefen Sie Ihr Wissen, indem Sie sich mit Gleichgesinnten vernetzen und an unseren nächsten Veranstaltungen Erfahrungen mit Experten austauschen.
- News
- Blog
- Kontakt

04. Juni 2025 •3 minutes read
Integration meets automation: Simplifying PRs with OpenAI
Danijel Dragičević
Software Developer
Maja Đajić
Software Engineer
Code reviews are crucial for effective development workflows, ensuring quality, maintainability, and adherence to best practices. They allow developers to assess solutions from multiple perspectives, uncover potential issues, and address overlooked edge cases.
However, solo developers often lack a second opinion, making it difficult to apply this practice consistently. Even in large teams, tight deadlines and heavy workloads can lead to rushed or superficial reviews, increasing the risk of undetected bugs or suboptimal code.
This is where AI can be a valuable ally. By automating aspects of pull request (PR) reviews, AI tools can identify potential issues, suggest improvements, and maintain a high standard of code quality without burdening developers with additional work.
In this post, we’ll explore how you can use AI for code review and integrate AI-powered pull request reviews into your GitHub workflow, enhancing efficiency and code quality while reducing the need for manual effort.
Building a Custom GitHub Action
To make AI-assisted PR reviews more easily reusable across projects, we packaged the functionality into a custom GitHub Action. This action automates the process by fetching the PR diff, analyzing the code using OpenAI’s API, and posting the review comments back to GitHub.
The action requires several inputs, including API keys and repository details, to ensure secure authentication and correct PR identification. Additionally, it supports optional parameters for customizing AI behavior, such as selecting the GPT model or setting token limits for responses. Here’s the action.yml file that defines the GitHub Action:
runs:<br> using: 'composite'<br> steps:<br> - name: Create temp directory<br> run: mkdir -p ${{ github.action_path }}/tmp<br> shell: bash<br><br> - name: Extract PR diff<br> run: |<br> git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > ${{ github.action_path }}/tmp/pr_diff.txt<br> echo "DIFF_FILE_PATH=${{ github.action_path }}/tmp/pr_diff.txt" >> $GITHUB_ENV<br> shell: bash<br><br> - name: Make script executable<br> run: chmod +x ${{ github.action_path }}/scripts/analyze-code.sh<br> shell: bash<br><br> - name: Analyze code with OpenAI<br> env:<br> OPENAI_API_KEY: ${{ inputs.OPENAI_API_KEY }}<br> GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}<br> REPOSITORY: ${{ inputs.REPOSITORY }}<br> PR_NUMBER: ${{ inputs.PR_NUMBER }}<br> DIFF_FILE_PATH: ${{ env.DIFF_FILE_PATH }}<br> GPT_MODEL: ${{ inputs.GPT_MODEL }}<br> MAX_TOKENS: ${{ inputs.MAX_TOKENS }}<br> run: ${{ github.action_path }}/scripts/analyze-code.sh \ <br> $OPENAI_API_KEY $GITHUB_TOKEN $REPOSITORY $PR_NUMBER \ <br> $DIFF_FILE_PATH $GPT_MODEL $MAX_TOKENS<br> shell: bash<br>
After passing these inputs, the action triggers a Bash script that handles the entire process in the background. The script:
- Extracts the PR diff.
- Sends the diff to OpenAI’s API for analysis.
- Receives AI-generated feedback.
- Posts the feedback as a comment on the pull request using the GitHub API.
This automation ensures consistent, efficient, and high-quality PR reviews while allowing developers to focus on more critical tasks.
Leveraging OpenAI API for AI code review
The OpenAI API is a powerful tool capable of generating insights, identifying code smells, and suggesting improvements. In our workflow, it plays a central role by analyzing PR changes and providing meaningful review comments.
To make this integration seamless, we need to craft a Bash script that:
- Prepares the AI prompt – Includes clear instructions and the extracted PR diff.
- Sends the request to OpenAI – Calls the API with a specified GPT model and token limit.
- Processes the AI response – Extracts a concise summary of the AI’s feedback.
This function sends a prompt along with the PR diff to OpenAI, allowing the AI to generate relevant feedback that will later be posted on GitHub.
# Function to send the prompt to OpenAI API and get the response<br>call_openai_api() {<br> local openai_api_key="$1"<br> local full_prompt="$2"<br> local gpt_model="$3"<br> local max_tokens="$4"<br><br> local messages_json<br> messages_json=$(jq -n --arg body "$full_prompt" '[{"role": "user", "content": $body}]')<br><br> curl -s -X POST "https://api.openai.com/v1/chat/completions" \<br> -H "Authorization: Bearer $openai_api_key" \<br> -H "Content-Type: application/json" \<br> -d "{\"model\": \"$gpt_model\", \"messages\": $messages_json, \"max_tokens\": $max_tokens}"<br>}<br>
GPT-4o-mini, which is used as a default model here, is an excellent choice for developers looking for an affordable yet high-quality AI-powered code review assistant. It strikes a balance between cost-effectiveness and intelligent analysis, making it ideal for teams that need quick, reliable feedback without the high expense of premium models. For this purpose, it is important to note that reviews from mini models are often faster and more concise, as they prioritize efficiency and are perfect for PR comments that need to be clear and to the point.
Using GitHub API to post an automated review
Once the AI generates feedback, the next step is to post the review as a comment on the PR using the GitHub API. This ensures that developers can access the AI insights directly within the code discussion, streamlining collaboration.
The function below formats the AI response and sends it as a PR comment:
# Function to post the summary as a comment on the pull request<br>post_summary_to_github() {<br> local github_token="$1"<br> local repository="$2"<br> local pr_number="$3"<br> local summary="$4"<br><br> local comment_body<br> comment_body=$(jq -n --arg body "$summary" '{body: $body}')<br><br> curl -s -X POST \<br> -H "Authorization: Bearer $github_token" \<br> -H "Content-Type: application/json" \<br> -d "$comment_body" \<br> "https://api.github.com/repos/$repository/issues/$pr_number/comments"<br>}<br>
Below is an example of how the AI-generated review appears on a pull request:
This blog post outlines the core steps of the GitHub Action, but the full implementation includes additional logic for error handling, input validation, and process automation. You can explore the complete source code on the GitHub Marketplace and easily integrate it into your repository. Check it out here: Analyze Pull Request with OpenAI.
Summary
We’ve explored how to automate pull request reviews using GitHub Actions and OpenAI API, reducing manual effort while maintaining code quality. By leveraging AI-powered insights, teams can:
- Streamline code review workflows
- Identify issues and improvements faster
- Ensure consistency across pull requests
As AI continues to evolve, automated code review assistants like this one will become even more powerful—helping developers write better software, faster.
Note: While this solution uses the OpenAI API, it’s crucial to be aware of and address privacy concerns when implementing such systems. Ensure that sensitive code is not inadvertently shared with external AI services.
Have you tried incorporating AI into your code review process? We’d love to hear about your experiences and insights!
Tags:
Danijel Dragičević
Software DeveloperDanijel Dragičević is a software developer and content creator who has been part of our family since April 2014. With a strong background in backend development, he has spent the past few years specializing in building robust services for API integrations. Passionate about clean code and efficient workflows, he continuously explores new technologies to enhance development processes.
Maja Đajić
Software EngineerMaja Đajić is a full-stack software developer at ProductDock with a passion for coding and problem-solving. She primarily works with Spring Boot and Angular but is always exploring new technologies. Currently completing her Software Engineering degree, Maja combines academic knowledge with hands-on experience to deliver robust, user-friendly applications.