This is a GitHub Action that automatically converts plain text into a well-structured Markdown document using the Gemini API. It's designed to streamline the process of creating and maintaining documentation, like README.md files, directly within your repository.
The workflow is simple and automated. You write your content in a plain text file, push your changes, and the GitHub Action handles the rest.
- Write Content: You write or paste your text into a designated source file (e.g.,
source.txt). - Commit & Push: You commit and push the changes to your repository.
- Workflow Trigger: The GitHub Action automatically detects the change to the
source.txtfile and starts the conversion process. - AI Conversion: A Python script uses the Gemini API to intelligently convert your text into Markdown, adding headings, lists, bold text, and other formatting as needed.
- Auto-Commit: The action then automatically commits the new or updated Markdown content to a destination file (e.g.,
README.md).
To use this tool in your own repository, you need to set up two files and one secret.
Place the following two files in your 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.
To securely use the Gemini API, you must store your API key as a GitHub Secret.
- Go to your repository's Settings > Secrets and variables > Actions.
- Click New repository secret.
- Set the Name to
GEMINI_API_KEY. - Paste your personal Gemini API key into the Secret field.
- Create a file named
source.txtin the root of your repository. - Add your plain text content to
source.txt. - 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.
Note: This readme is also created using this workflow.