Skip to content

Commit 639661d

Browse files
authored
Merge pull request #79 from rajbos/copilot/update-check-for-copilot-models
Add automatic issue closure to Check for Copilot Model Updates workflow
2 parents 90b874d + 6e94f26 commit 639661d

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/check-models.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
paths:
77
- .github/workflows/check-models.yml
88
- .github/scripts/scrape-models.sh
9+
- src/tokenEstimators.json
10+
- src/modelPricing.json
911

1012
schedule:
1113
- cron: '11 17 * * 1' # Run every Monday at 5:11 PM UTC
@@ -180,3 +182,44 @@ jobs:
180182
});
181183
console.log('Created a new GitHub issue for missing models.');
182184
}
185+
186+
- name: Close GitHub Issue if all models are up-to-date
187+
if: steps.check_missing.outputs.needs_update == 'false'
188+
uses: actions/github-script@v7
189+
with:
190+
github-token: ${{ secrets.GITHUB_TOKEN }}
191+
script: |
192+
const { owner, repo } = context.repo;
193+
194+
// Find open issues with the specific title and labels
195+
const { data: issues } = await github.rest.issues.listForRepo({
196+
owner,
197+
repo,
198+
state: 'open',
199+
labels: 'maintenance',
200+
creator: 'github-actions[bot]'
201+
});
202+
203+
const title = '🤖 Action Required: Update Copilot Supported Models';
204+
const existingIssue = issues.find(issue => issue.title === title);
205+
206+
if (existingIssue) {
207+
// Close the issue with a comment
208+
await github.rest.issues.createComment({
209+
owner,
210+
repo,
211+
issue_number: existingIssue.number,
212+
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.'
213+
});
214+
215+
await github.rest.issues.update({
216+
owner,
217+
repo,
218+
issue_number: existingIssue.number,
219+
state: 'closed'
220+
});
221+
222+
console.log(`Closed issue #${existingIssue.number} as all models are now up-to-date.`);
223+
} else {
224+
console.log('No open issue found to close. All models are already up-to-date.');
225+
}

0 commit comments

Comments
 (0)