type Github = {
token: string;
};
/**
* Export a codespace for the authenticated user
* Triggers an export of the specified codespace and returns a URL and ID where the status of the export can be monitored.
If changes cannot be pushed to the codespace's repository, they will be pushed to a new or previously-existing fork instead.
You must authenticate using a personal access token with the `codespace` scope to use this endpoint.
GitHub Apps must have write access to the `codespaces_lifecycle_admin` repository permission to use this endpoint.
*/
export async function main(auth: Github, codespace_name: string) {
const url = new URL(
`https://api.github.com/user/codespaces/${codespace_name}/exports`
);
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 367 days ago
type Github = {
token: string;
};
/**
* Export a codespace for the authenticated user
* Triggers an export of the specified codespace and returns a URL and ID where the status of the export can be monitored.
If changes cannot be pushed to the codespace's repository, they will be pushed to a new or previously-existing fork instead.
You must authenticate using a personal access token with the `codespace` scope to use this endpoint.
GitHub Apps must have write access to the `codespaces_lifecycle_admin` repository permission to use this endpoint.
*/
export async function main(auth: Github, codespace_name: string) {
const url = new URL(
`https://api.github.com/user/codespaces/${codespace_name}/exports`
);
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 927 days ago