Skip to content

feat: Add Product Update Automation (Targeting product-updates branch)#1518

Closed
AjinkyaM1 wants to merge 4 commits intouser-guides-pubfrom
feat/product-update-automation
Closed

feat: Add Product Update Automation (Targeting product-updates branch)#1518
AjinkyaM1 wants to merge 4 commits intouser-guides-pubfrom
feat/product-update-automation

Conversation

@AjinkyaM1
Copy link
Contributor

🚀 Product Update Automation

This PR introduces an automated system to generate monthly product updates using Gemini AI.

📦 Included Changes

  • scripts/generate_updates.js: The core script that fetches closed PRs, retrieves linked issue context, and uses Gemini to write a marketing-focused update.
    • Note: Configured to use .gemini/styleguide.md for style instructions.
  • package.json: Required dependencies (@google/generative-ai, @octokit/rest).

⚠️ Manual Action Required

I was unable to push the .github/workflows/generate-updates.yml file due to permission restrictions. Please add the following file manually to .github/workflows/:

name: Generate Monthly Product Updates
on:
  schedule: [{cron: '0 0 1 * *'}]
  workflow_dispatch:
permissions:
  contents: write
  pull-requests: write
jobs:
  run:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with: {node-version: '18'}
      - run: npm install
      - env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
          REPOSITORIES: "hotwax"
        run: node scripts/generate_updates.js
      - uses: peter-evans/create-pull-request@v5
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          title: "Monthly Product Update"
          branch: "docs/product-update"

📋 Setup Checklist

  1. Add GEMINI_API_KEY to Repository Secrets.
  2. Ensure GitHub Actions has "Read and write permissions" in Settings.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @AjinkyaM1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces an automated system designed to streamline the creation of monthly product updates. By integrating with GitHub and Google's Gemini AI, it automatically gathers information from recently closed pull requests and their associated issues, then uses AI to generate polished, customer-facing release notes. This significantly reduces manual effort in communicating product advancements and ensures consistent, high-quality updates.

Highlights

  • Automated Product Updates: Introduces a new system to automatically generate monthly product updates, reducing manual effort and ensuring timely communication.
  • AI-Powered Content Generation: Leverages Google's Gemini AI to transform technical pull request details into marketing-focused, customer-friendly release notes.
  • GitHub Integration: The system integrates with GitHub to fetch recently closed pull requests and their linked issue context, providing rich data for AI generation.
  • Configurable Style Guide: Supports using a custom style guide (e.g., .gemini/styleguide.md) to instruct the AI on the desired tone, formatting, and structure for the product updates.
  • New Dependencies: Adds @google/generative-ai and @octokit/rest to package.json to facilitate AI interaction and GitHub API calls.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable automation for generating monthly product updates by fetching data from GitHub and using Gemini AI to create marketing-friendly content. However, a medium-severity prompt injection vulnerability was identified where untrusted data from GitHub is directly concatenated into the LLM prompt, which could be exploited to manipulate the generated product updates. Recommendations for mitigation include using delimiters and refining the system prompt. Additionally, suggestions were made to improve robustness, performance, and maintainability, including a critical fix to prevent the monthly update file from being overwritten, improved error logging, parallelizing API calls, and removing an unused import. Addressing these points will make the script more resilient, efficient, and secure.

if (!content) throw new Error("AI servers are unavailable. Try again in 5 minutes.");

if (!fs.existsSync('product-updates')) fs.mkdirSync('product-updates');
fs.writeFileSync(`product-updates/${new Date().getFullYear()}.md`, content);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The current filename for the product update is based only on the year. Since this script is intended to run monthly, this will cause the same file to be overwritten with each run within the same year, leading to loss of previous months' updates. The filename should be unique for each month to prevent data loss.

        fs.writeFileSync(`product-updates/${new Date().toISOString().slice(0, 7)}.md`, content);

Output: Scannable, customer-ready Product Update suitable for release notes or announcements.
`;

const prompt = `${instruction}\n\nStyle Guide:\n${style}\n\nChanges:\n${prSummaries}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

security-medium medium

The script fetches pull request titles and issue descriptions from GitHub and concatenates them directly into the prompt sent to the Gemini LLM. This allows an attacker with the ability to create PRs or issues in the target repositories to perform a prompt injection attack, potentially manipulating the generated product updates. Since the output is intended to be customer-facing, this poses a risk to the brand's reputation and the integrity of the communication.

To mitigate this, use clear delimiters to separate untrusted data from instructions and update the system prompt to explicitly ignore any instructions contained within those delimiters.

Suggested change
const prompt = `${instruction}\n\nStyle Guide:\n${style}\n\nChanges:\n${prSummaries}`;
const prompt = instruction + "\n\nStyle Guide:\n" + style + "\n\nChanges (Untrusted Data):\n<data>\n" + prSummaries + "\n</data>";

const { Octokit } = require("@octokit/rest");
const { GoogleGenerativeAI } = require("@google/generative-ai");
const fs = require('fs');
const path = require('path');
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The path module is imported but is not used anywhere in the file. It's best practice to remove unused imports to keep the code clean.

Comment on lines +34 to +44
const results = [];
for (const pr of merged) {
let issueContext = "";
const issueMatch = pr.body && pr.body.match(/(?:fix|fixes|fixed|close|closes|closed|resolve|resolves|resolved)\s+#(\d+)/i);
if (issueMatch) {
const issueNumber = issueMatch[1];
const details = await getIssueDetails(owner, repo, issueNumber);
if (details) issueContext = details;
}
results.push({ repository: `${owner}/${repo}`, title: pr.title, context: issueContext });
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The current implementation fetches issue details for each pull request sequentially within a for...of loop. This can be inefficient and slow if there are many pull requests. You can significantly speed up the process by executing these API calls in parallel using Promise.all.

        const results = await Promise.all(merged.map(async (pr) => {
            let issueContext = "";
            const issueMatch = pr.body && pr.body.match(/(?:fix|fixes|fixed|close|closes|closed|resolve|resolves|resolved)\s+#(\d+)/i);
            if (issueMatch) {
                const issueNumber = issueMatch[1];
                const details = await getIssueDetails(owner, repo, issueNumber);
                if (details) issueContext = details;
            }
            return { repository: `${owner}/${repo}`, title: pr.title, context: issueContext };
        }));

results.push({ repository: `${owner}/${repo}`, title: pr.title, context: issueContext });
}
return results;
} catch (e) { return []; }
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The catch block currently returns an empty array without logging the error. This practice, known as error swallowing, can make debugging very difficult if an issue occurs while fetching pull requests (e.g., invalid token, network error, rate limiting). It's better to log the error to maintain visibility into potential problems.

    } catch (e) { console.error(`Failed to fetch PRs for ${owner}/${repo}: ${e.message}`); return []; }

- Parallelized repo scanning for better performance
- Added prompt delimiters to prevent injection
- Improved error logging in catch blocks
- Fixed file overwriting by using YYYY-MM naming
- Removed unused 'path' import
@AjinkyaM1
Copy link
Contributor Author

✅ Feedback Addressed

I have updated the PR to address all points from the Gemini Code Assist review:

  • 🔐 Prompt Injection Protection: Added XML-style delimiters (<STYLE_GUIDE>, <RAW_CHANGES>) to the AI prompt to clearly separate instructions from untrusted GitHub data.
  • 🚀 Performance Optimization: Implemented parallel repository fetching using Promise.all(), significantly reducing the total run time for large organizations.
  • 📁 Robust File Naming: Updated the output filename to YYYY-MM.md format. This ensures that monthly updates don't overwrite each other if the script is run multiple times in a year.
  • 📢 Improved Error Logging: Added descriptive logging to catch blocks instead of returning empty results silently.
  • 🧹 Code Cleanup: Removed the unused path import.

The automation is now faster, more secure, and enterprise-ready. 🚀

@AjinkyaM1 AjinkyaM1 self-assigned this Jan 31, 2026
@AjinkyaM1 AjinkyaM1 changed the title feat: Add Product Update Automation feat: Add Product Update Automation (Targeting product-updates branch) Jan 31, 2026
@AjinkyaM1
Copy link
Contributor Author

🔄 Target Branch Updated

As requested, I have created the new base branch product-updates.

I have also updated this PR to target product-updates as its base. All future monthly product updates generated by this automation will now be proposed as PRs into the product-updates branch.

Workflow Revision:
Please ensure the manually created .github/workflows/generate-updates.yml file uses base: "product-updates":

      - uses: peter-evans/create-pull-request@v5
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          title: "Monthly Product Update"
          branch: "docs/product-update"
          base: "product-updates" # <--- Updated

@AjinkyaM1 AjinkyaM1 closed this Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments