Collect data for ChatGPT assistant #9
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@v4 | |
- name: Collect GitHub issue and release data | |
shell: pwsh | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
$repo = $env:GITHUB_REPOSITORY | |
$token = $env:GITHUB_TOKEN | |
$headers = @{ "Authorization" = "token $token" } | |
$repoRoot = $env:GITHUB_WORKSPACE | |
# Collect issues | |
$issues = @() | |
$page = 1 | |
do { | |
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/issues?state=all&page=$page&per_page=100" -Headers $headers | |
if ($response.Count -eq 0) { break } | |
$issues += $response | |
$page++ | |
} while ($true) | |
Out-File -FilePath "issues.md" -Encoding utf8 -InputObject "" | |
foreach ($issue in $issues) { | |
Add-Content -Path "issues.md" -Value "## #$($issue.number) - $($issue.title)`n$($issue.body)`n" | |
$commentsUrl = $issue.comments_url | |
$comments = Invoke-RestMethod -Uri $commentsUrl -Headers $headers | |
if ($comments.Count -gt 0) { | |
Add-Content -Path "issues.md" -Value "### Comments:`n" | |
foreach ($comment in $comments) { | |
Add-Content -Path "issues.md" -Value "- **$($comment.user.login)**: $($comment.body)`n" | |
} | |
Add-Content -Path "issues.md" -Value "`n" | |
} | |
} | |
# Collect releases | |
$releases = @() | |
$page = 1 | |
do { | |
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases?page=$page&per_page=100" -Headers $headers | |
if ($response.Count -eq 0) { break } | |
$releases += $response | |
$page++ | |
} while ($true) | |
Out-File -FilePath "releases.md" -Encoding utf8 -InputObject "" | |
foreach ($release in $releases) { | |
Add-Content -Path "releases.md" -Value "## $($release.tag_name) - $($release.name)`n$($release.body)`n" | |
} | |
# Collect important code snippets | |
$importantFiles = @( | |
"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" | |
) | |
Out-File -FilePath "code_snippets.md" -Encoding utf8 -InputObject "" | |
foreach ($filePath in $importantFiles) { | |
Add-Content -Path "code_snippets.md" -Value "## $filePath`n" | |
$fullPath = Join-Path -Path $repoRoot -ChildPath $filePath | |
Write-Output "Checking path: $fullPath" # Debugging | |
if (Test-Path $fullPath) { | |
$content = Get-Content -Path $fullPath -Raw | Out-String | |
Add-Content -Path "code_snippets.md" -Value "``````csharp" | |
Add-Content -Path "code_snippets.md" -Value $content | |
Add-Content -Path "code_snippets.md" -Value "``````n" | |
} else { | |
Write-Error "File not found: $fullPath" exit 1 # Fail the script if a file is not found | |
} | |
} | |
- name: Upload data artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: data | |
path: "*.md" |