-
Notifications
You must be signed in to change notification settings - Fork 2.1k
added example of github actions #915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
ROHANDWIVEDI2005
commented
Aug 26, 2025
- Added an example of a txt to markdown converter github action
- Demonstrates the use of gemini api in github-action work flows.
There was a problem hiding this 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
-
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. ↩
There was a problem hiding this 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def convert_to_markdown(text_content,api_key): | ||
|
||
|
||
client = genai.Client(api_key = api_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the Google Python Style Guide, which this project follows, there should be no spaces around the =
sign for keyword arguments.1
client = genai.Client(api_key = api_key) | |
client = genai.Client(api_key=api_key) |
Style Guide References
Footnotes
print("Markdown conversion failed.") | ||
|
||
if __name__ == "__main__": | ||
main() No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 beactions/checkout@v4
actions/setup-python@v4
should beactions/setup-python@v5
stefanzweifel/git-auto-commit-action@v4
should bestefanzweifel/git-auto-commit-action@v5
* **`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`**: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
* **`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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a newline at the end of the file. It's a standard convention for text files.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolves issue #911 |