Collect data for ChatGPT assistant #4
Workflow file for this run
This file contains 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: Collect data for ChatGPT assistant | |
on: | |
workflow_dispatch: | |
permissions: | |
issues: read | |
contents: read | |
jobs: | |
collect-data: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests | |
- name: Collect GitHub issue and release data | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
python <<EOF | |
import requests | |
import os | |
repo = os.getenv('GITHUB_REPOSITORY') | |
token = os.getenv('GITHUB_TOKEN') | |
headers = {'Authorization': f'token {token}'} | |
# Collect issues | |
issues = [] | |
page = 1 | |
while True: | |
response = requests.get(f'https://api.github.com/repos/{repo}/issues', headers=headers, params={'state': 'all', 'page': page, 'per_page': 100}) | |
data = response.json() | |
if not data: | |
break | |
issues.extend(data) | |
page += 1 | |
with open('issues.md', 'w') as f: | |
for issue in issues: | |
f.write(f"## #{issue['number']} - {issue['title']}\n") | |
f.write(f"{issue['body']}\n\n") | |
comments_url = issue['comments_url'] | |
comments_response = requests.get(comments_url, headers=headers) | |
comments = comments_response.json() | |
if comments: | |
f.write("### Comments:\n") | |
for comment in comments: | |
f.write(f"- **{comment['user']['login']}**: {comment['body']}\n") | |
f.write("\n") | |
# Collect releases | |
releases = [] | |
page = 1 | |
while True: | |
response = requests.get(f'https://api.github.com/repos/{repo}/releases', headers=headers, params={'page': page, 'per_page': 100}) | |
data = response.json() | |
if not data: | |
break | |
releases.extend(data) | |
page += 1 | |
with open('releases.md', 'w') as f: | |
for release in releases: | |
f.write(f"## {release['tag_name']} - {release['name']}\n") | |
f.write(f"{release['body']}\n\n") | |
# Collect important code snippets | |
important_files = [ | |
'Whisper.net/LibraryLoader/NativeLibraryLoader.cs', | |
'Whisper.net/WhisperProcessorBuilder.cs', | |
'Whisper.net/WhisperFactory.cs', | |
'Whisper.net/WhisperProcessor.cs', | |
'Whisper.net/LibraryLoader/RuntimeOptions.cs', | |
'examples/Simple/Program.cs', | |
'examples/NAudioResampleWav/Program.cs', | |
'examples/ParallelExecution/Program.cs' | |
] | |
with open('code_snippets.md', 'w') as f: | |
for file_path in important_files: | |
f.write(f"## {file_path}\n") | |
with open(file_path, 'r', encoding='utf-8') as code_file: | |
f.write("```csharp\n") | |
f.write(code_file.read()) | |
f.write("\n```\n\n") | |
EOF | |
- name: Upload data artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: data | |
path: "*.md" |