Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/check_updates.generated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
- name: Run script
env:
OPENAI_API_KEY: '${{ secrets.OPENAI_API_KEY }}'
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
CODEX_MODEL: gpt-6.1-sol
REVIEW_MODEL: gpt-6-astra
run: |-
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/check_updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const buildJob = {
name: "Run script",
env: {
OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}",
// for the requests the update script makes to GitHub
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}",
// model that fixes/wires up the Mago update (Codex)
CODEX_MODEL: "gpt-6.1-sol",
// separate model that independently reviews the changes
Expand Down
14 changes: 12 additions & 2 deletions scripts/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ async function getLatestMagoVersions(): Promise<MagoVersions> {

async function updateRustToolchain(magoVersion: string) {
const content = await $.request(
`https://raw.githubusercontent.com/carthage-software/mago/${magoVersion}/Cargo.toml`,
).text();
`https://api.github.com/repos/carthage-software/mago/contents/Cargo.toml?ref=${encodeURIComponent(magoVersion)}`,
).header(getGitHubHeaders()).text();
const match = content.match(/rust-version\s*=\s*"([^"]+)"/);
if (match == null) {
throw new Error("Could not find rust-version in mago's Cargo.toml.");
Expand Down Expand Up @@ -214,3 +214,13 @@ async function getLatestCrateVersion(crateName: string): Promise<string> {
$.logLight(`Latest ${crateName} version on crates.io:`, latestVersion);
return latestVersion;
}

// Asks the GitHub API for raw file content. It authenticates when there's a
// token, since unauthenticated requests get rate limited on the runners' shared IPs.
function getGitHubHeaders(): Record<string, string> {
const token = Deno.env.get("GITHUB_TOKEN");
return {
accept: "application/vnd.github.raw+json",
...(token ? { authorization: `Bearer ${token}` } : {}),
};
}
Loading