Skip to content

Conversation

ROHANDWIVEDI2005
Copy link
Contributor

  • Added an example of a txt to markdown converter github action
  • Demonstrates the use of gemini api in github-action work flows.

@github-actions github-actions bot added status:awaiting review PR awaiting review from a maintainer component:examples Issues/PR referencing examples folder labels Aug 26, 2025
Copy link

@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.

Summary of Changes

Hello @ROHANDWIVEDI2005, 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 a new example of a GitHub Action designed to automate the conversion of plain text files into well-structured Markdown documents. It leverages the Gemini API to intelligently format the text, streamlining the process of generating documentation like README.md files within a repository.

Highlights

  • New GitHub Action Example: Adds a complete example of a GitHub Action that converts plain text (source.txt) into a formatted Markdown file (README.md).
  • Gemini API Integration: Demonstrates the use of the Gemini API within a GitHub Actions workflow for AI-powered text formatting and structuring.
  • Automated Documentation: Enables automated generation and updating of README.md files, reducing manual effort in documentation maintenance.
  • Setup and Usage Documentation: Includes comprehensive readme.md files detailing how to set up and use the new GitHub Action, including API key management and repository permissions.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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

@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 adds a helpful example of a GitHub Action that uses the Gemini API to convert a text file to Markdown. The implementation is a good start, but there are several areas for improvement in the Python script, the GitHub workflow configuration, and the documentation.

My review focuses on:

  • Python Script: Improving robustness by using more specific exception handling, enhancing reusability with command-line arguments instead of hardcoded filenames, and adhering to the project's Python style guide.
  • GitHub Workflow: Updating outdated actions and correcting the branch configuration to ensure it works correctly for pull requests and feature branches.
  • Documentation: Fixing a broken link and improving the clarity of the setup instructions.



return response.text
except Exception as e:

Choose a reason for hiding this comment

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

high

Catching a generic Exception is too broad and can hide bugs or prevent specific error handling. It's better to catch more specific exceptions, such as those from google.api_core.exceptions, to handle potential API errors more precisely.

Comment on lines +45 to +46
input_file = "source.txt" # You can change this to your input file
output_file = "README.md" # You can change this to your desired output file

Choose a reason for hiding this comment

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

high

Hardcoding filenames makes the script less reusable and can lead to accidentally overwriting important files like the main README.md. It's better to accept file paths as command-line arguments, for example, by using Python's argparse module.

uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'Auto-generate README.md from source.txt'
branch: main No newline at end of file

Choose a reason for hiding this comment

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

high

Hardcoding branch: main will prevent this action from working correctly on pull requests or feature branches. The git-auto-commit-action defaults to committing to the current branch, which is the desired behavior here. Please remove this line to allow the action to work on any branch. Also, the file is missing a final newline.

Because the workflows run on GitHub's servers, they have direct access to your repository's files and can use secrets to securely handle your API keys. This creates a powerful, hands-off automation system.

## Examples
* [AI Text to Markdown Converter](./ai-markdown-converter/README.md) No newline at end of file

Choose a reason for hiding this comment

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

high

This link appears to be broken. The directory for the example is markdown-converter, not ai-markdown-converter.

Suggested change
* [AI Text to Markdown Converter](./ai-markdown-converter/README.md)
* [AI Text to Markdown Converter](./markdown-converter/readme.md)

def convert_to_markdown(text_content,api_key):


client = genai.Client(api_key = api_key)

Choose a reason for hiding this comment

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

medium

According to the Google Python Style Guide, which this project follows, there should be no spaces around the = sign for keyword arguments.1

Suggested change
client = genai.Client(api_key = api_key)
client = genai.Client(api_key=api_key)

Style Guide References

Footnotes

  1. The project's style guide specifies the use of the Google Python Style Guide. (link)

print("Markdown conversion failed.")

if __name__ == "__main__":
main() No newline at end of file

Choose a reason for hiding this comment

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

medium

The file is missing a final newline, which is a standard convention for text files.

Suggested change
main()
main()

Comment on lines +28 to +51
uses: actions/checkout@v3


- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'


- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install google-genai


- name: Run Markdown Converter Script
run: python convert_to_md.py
env:

GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}


- name: Commit and Push Changes
uses: stefanzweifel/git-auto-commit-action@v4

Choose a reason for hiding this comment

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

medium

Several of the GitHub Actions used in this workflow are outdated. It's recommended to update them to their latest major versions to benefit from new features, performance improvements, and security patches:

  • actions/checkout@v3 should be actions/checkout@v4
  • actions/setup-python@v4 should be actions/setup-python@v5
  • stefanzweifel/git-auto-commit-action@v4 should be stefanzweifel/git-auto-commit-action@v5

Comment on lines +23 to +26
* **`convert_to_md.py`**: This script contains the logic for the AI conversion.
* **`.github/workflows/generate-markdown.yml`**: This YAML file defines the GitHub Action workflow.

* **`structure of the repository`**:

Choose a reason for hiding this comment

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

medium

The formatting of this list is a bit confusing. The last item, 'structure of the repository', seems like it should be a sub-heading or regular text rather than a bullet point in the list of files.

Suggested change
* **`convert_to_md.py`**: This script contains the logic for the AI conversion.
* **`.github/workflows/generate-markdown.yml`**: This YAML file defines the GitHub Action workflow.
* **`structure of the repository`**:
* **`convert_to_md.py`**: This script contains the logic for the AI conversion.
* **`.github/workflows/generate-markdown.yml`**: This YAML file defines the GitHub Action workflow.
**Repository Structure**:

2. Add your plain text content to `source.txt`.
3. Commit and push your changes.

The workflow will run automatically, and you will see a new `README.md` file created with the formatted Markdown content. No newline at end of file

Choose a reason for hiding this comment

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

medium

Please add a newline at the end of the file. It's a standard convention for text files.

Suggested change
The workflow will run automatically, and you will see a new `README.md` file created with the formatted Markdown content.
The workflow will run automatically, and you will see a new `README.md` file created with the formatted Markdown content.

Because the workflows run on GitHub's servers, they have direct access to your repository's files and can use secrets to securely handle your API keys. This creates a powerful, hands-off automation system.

## Examples
* [AI Text to Markdown Converter](./ai-markdown-converter/README.md) No newline at end of file

Choose a reason for hiding this comment

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

medium

Please add a newline at the end of the file. It's a standard convention for text files.

Suggested change
* [AI Text to Markdown Converter](./ai-markdown-converter/README.md)
* [AI Text to Markdown Converter](./ai-markdown-converter/README.md)

@ROHANDWIVEDI2005
Copy link
Contributor Author

Resolves issue #911

@ROHANDWIVEDI2005 ROHANDWIVEDI2005 marked this pull request as draft August 28, 2025 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:examples Issues/PR referencing examples folder status:awaiting review PR awaiting review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant