Readme Gen #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate README | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| generate-readme: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Generate README | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| run: | | |
| pip install openai | |
| python - <<'EOF' | |
| import os, openai | |
| files = [f for f in os.listdir('.') if os.path.isfile(f)] | |
| prompt = f"Generate a professional README.md for a project containing these files: {files}" | |
| response = openai.ChatCompletion.create( | |
| model="gpt-4o-mini", | |
| messages=[{"role": "user", "content": prompt}] | |
| ) | |
| with open("README.md", "w") as f: | |
| f.write(response.choices[0].message["content"]) | |
| EOF | |
| - name: Commit and push README | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "[email protected]" | |
| git add README.md | |
| git commit -m "Auto-generated README" | |
| git push |