Skip to content

Commit

Permalink
for codespace, fetch .vsix from releases instead of action runs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Donham committed Jul 24, 2024
1 parent 8513b31 commit 7c4f8fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"extensions": []
}
},
"postCreateCommand": "pnpm install && pnpm add npm:@githubnext/vitale && node ./scripts/fetch_latest_vsix.mjs && unzip -o latest-vsix.zip",
"postCreateCommand": "pnpm install && pnpm add npm:@githubnext/vitale && node ./scripts/fetch_latest_vsix.mjs",
"waitFor": "postCreateCommand",
"postAttachCommand": " code --install-extension ./vitale-*.vsix",
"portsAttributes": {
Expand Down
17 changes: 8 additions & 9 deletions packages/examples/scripts/fetch_latest_vsix.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,28 @@ import * as fs from "node:fs";

const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });

const runs = await octokit.request(
"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs",
const release = await octokit.request(
"GET /repos/{owner}/{repo}/releases/latest",
{
owner: "githubnext",
repo: "vitale",
workflow_id: "vsix.yml",
per_page: 1,
}
);

const artifacts = await octokit.request(
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts",
const assets = await octokit.request(
"GET /repos/{owner}/{repo}/releases/{release_id}/assets",
{
owner: "githubnext",
repo: "vitale",
run_id: runs.data.workflow_runs[0].id,
release_id: release.data.id,
}
);
const asset = assets.data[0];

const res = await fetch(artifacts.data.artifacts[0].archive_download_url, {
const res = await fetch(asset.browser_download_url, {
headers: {
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
},
});

Readable.fromWeb(res.body).pipe(fs.createWriteStream("latest-vsix.zip"));
Readable.fromWeb(res.body).pipe(fs.createWriteStream(asset.name));

0 comments on commit 7c4f8fc

Please sign in to comment.