add pull request function
This commit is contained in:
parent
2961bc4418
commit
4a9a986935
|
@ -1,8 +1,28 @@
|
|||
// Sample function only, actual functions needed may be different
|
||||
function makePullRequest() {
|
||||
console.log("TODO: Make pull request");
|
||||
// TODO: Remove this, for demo purposes only!
|
||||
console.log(`API KEY: ${process.env.GITEA_API_KEY}`);
|
||||
}
|
||||
import fetch from 'node-fetch';
|
||||
import 'dotenv/config'
|
||||
|
||||
export { makePullRequest };
|
||||
export const MAIN_BRANCH = "main"
|
||||
export const GITEA_API_URL = "https://git.csclub.uwaterloo.ca/api/v1/repos"
|
||||
|
||||
export const makePullRequest = async (owner: string, repoName: string, title: string, body:string, branchName: string, assignee: string) => {
|
||||
const PULL_URL = `${GITEA_API_URL}/${owner}/${repoName}/pulls`
|
||||
console.log(PULL_URL)
|
||||
|
||||
const response = await fetch(PULL_URL, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${process.env.GITEA_API_KEY}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
assignee: assignee,
|
||||
base: MAIN_BRANCH,
|
||||
title: title,
|
||||
body: body,
|
||||
head: branchName,
|
||||
})
|
||||
});
|
||||
const content = await response.json();
|
||||
return content
|
||||
}
|
Loading…
Reference in New Issue