type Gitlab = {
baseUrl: string;
token: string;
};
export async function main(
glab: Gitlab,
projectId: number,
mergeRequestId: number,
comment: string
) {
const url = `${glab.baseUrl}/api/v4/projects/${projectId}/merge_requests/${mergeRequestId}/notes`;
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${glab.token}`,
},
body: JSON.stringify({ body: comment }),
});
if (!response.ok) {
throw new Error(`Error ${response.status}: ${response.statusText}`);
}
return await response.json();
}
Submitted by jaumebosch628 198 days ago