Skip to content

Collect data for ChatGPT assistant #1

Collect data for ChatGPT assistant

Collect data for ChatGPT assistant #1

name: Collect data for ChatGPT assistant
on:
workflow_dispatch:
permissions:
issues: read
jobs:
collect-issues:
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 issues
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}'}
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")
EOF
- name: Upload issues artifact
uses: actions/upload-artifact@v3
with:
name: issues
path: issues.md