Skip to content

Instantly share code, notes, and snippets.

View maskaravivek's full-sized avatar
💭
Active!

Vivek Kumar Maskara maskaravivek

💭
Active!
View GitHub Profile
POST https://api.github.com/repos/{user}/{repo}/git/commits
const updateGithubBranchRef = async (
githubAccessToken,
repoFullName,
branchName,
commitSha
) => {
const payload = {
sha: commitSha,
force: false,
};
PATCH https://api.github.com/repos/{user}/{repo}/git/refs/heads/{branch}
const getParentSha = async (githubAccessToken, repoFullName, branchName) => {
const parentResp = await fetch(
`https://api.github.com/repos/${repoFullName}/git/refs/heads/${branchName}`,
{
method: "GET",
headers: {
Accept: "application/vnd.github+json",
Authorization: `Bearer ${githubAccessToken}`,
"X-GitHub-Api-Version": "2022-11-28",
},
https://api.github.com/repos/${user}/{repo}/git/refs/heads/{branch}
const createGithubRepoTree = async (
githubAccessToken,
repoFullName,
branchName,
articleFiles
) => {
const shaForBaseTree = await getShaForBaseTree(
githubAccessToken,
repoFullName,
branchName
POST https://api.github.com/repos/{user}/{repo}/git/trees
const createGithubFileBlob = async (
githubAccessToken,
repoFullName,
content,
encoding = "utf-8"
) => {
const blobResp = await fetch(
`https://api.github.com/repos/${repoFullName}/git/blobs`,
{
method: "POST",
POST https://api.github.com/repos/{user}/{repo}/git/blobs
const getShaForBaseTree = async (
githubAccessToken,
repoFullName,
branchName
) => {
const baseTreeResp = await fetch(
`https://api.github.com/repos/${repoFullName}/git/trees/${branchName}`,
{
method: "GET",
headers: {