diff --git a/.github/workflows/check-models.yml b/.github/workflows/check-models.yml index 35519706..3120d326 100644 --- a/.github/workflows/check-models.yml +++ b/.github/workflows/check-models.yml @@ -6,6 +6,8 @@ on: paths: - .github/workflows/check-models.yml - .github/scripts/scrape-models.sh + - src/tokenEstimators.json + - src/modelPricing.json schedule: - cron: '11 17 * * 1' # Run every Monday at 5:11 PM UTC @@ -180,3 +182,44 @@ jobs: }); console.log('Created a new GitHub issue for missing models.'); } + + - name: Close GitHub Issue if all models are up-to-date + if: steps.check_missing.outputs.needs_update == 'false' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { owner, repo } = context.repo; + + // Find open issues with the specific title and labels + const { data: issues } = await github.rest.issues.listForRepo({ + owner, + repo, + state: 'open', + labels: 'maintenance', + creator: 'github-actions[bot]' + }); + + const title = '🤖 Action Required: Update Copilot Supported Models'; + const existingIssue = issues.find(issue => issue.title === title); + + if (existingIssue) { + // Close the issue with a comment + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: '✅ All Copilot models are now up-to-date. All models from the [GitHub Copilot documentation](https://docs.github.com/en/copilot/reference/ai-models/supported-models) are present in both `tokenEstimators.json` and `modelPricing.json`.\n\nClosing this issue automatically.' + }); + + await github.rest.issues.update({ + owner, + repo, + issue_number: existingIssue.number, + state: 'closed' + }); + + console.log(`Closed issue #${existingIssue.number} as all models are now up-to-date.`); + } else { + console.log('No open issue found to close. All models are already up-to-date.'); + }