Skip to content

add some logs in production #78

add some logs in production

add some logs in production #78

name: ChatGPT Workflow
on:
push:
paths:
- 'src/tasks.py'
workflow_dispatch:
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Check for rebuild-docs
run: |
echo "Commit message: '${{ steps.commit.outputs.message }}'"
if [[ "${{ steps.commit.outputs.message }}" == *"--rebuild-docs"* ]]; then
echo "Commit message contains --rebuild-docs. Continue to next step."
else
echo "Commit message does not contain --rebuild-docs. Skipping subsequent steps."
exit 78
shell: bash
continue-on-error: true
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install openai
- name: Read tasks.py and Generate README
run: |
python -c "
import openai
import os
# Read content
with open('src/tasks.py', 'r') as file:
lines = file.readlines()
start_line = next(i for i, line in enumerate(lines, start=1) if '# auto-generated SQLite documentation starts here' in line)
content = ''.join(lines[start_line-1:])
# Call to ChatGPT
openai.api_key = os.getenv('OPENAI_API_KEY')
prompt = content
response = openai.ChatCompletion.create(model='gpt-4', messages=[{'role': 'user', 'content': f'{prompt}\nGenerate a documentation markdown table for each table of the SQLite database (including package_data). For example:\n\n**activity table**\n|Column|Description\n|event_name|One sentence to explain to the developers what kind of data they will find here. If the code provided allows you to provide an example of data format or value that is great, but do not invent anything.|same for this column|etc.\n\n**Table 2**\n|Column|Description|...\n\netc.'}])
readme_content = response.choices[0].message.content.strip()
# Write to db_doc.md
with open('docs/sqlite_database_structure.md', 'w') as file:
readme_content = 'Note: this documentation was generated automatically from the tasks.py code using an AI. Although we are confident in the reliability of the data displayed here, errors may occur.\n\n\n' + readme_content
file.write(readme_content)
"
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- name: Commit and Push
uses: EndBug/add-and-commit@v7
with:
message: 'Update sqlite_database_structure.md'
add: 'docs/sqlite_database_structure.md'