Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maskaravivek/98ed0e77a07e8357df5c04d98d73e610 to your computer and use it in GitHub Desktop.
Save maskaravivek/98ed0e77a07e8357df5c04d98d73e610 to your computer and use it in GitHub Desktop.
const updateGithubBranchRef = async (
githubAccessToken,
repoFullName,
branchName,
commitSha
) => {
const payload = {
sha: commitSha,
force: false,
};
const response = await fetch(
`https://api.github.com/repos/${repoFullName}/git/refs/heads/${branchName}`,
{
method: "PATCH",
headers: {
Accept: "application/vnd.github+json",
Authorization: `Bearer ${githubAccessToken}`,
"X-GitHub-Api-Version": "2022-11-28",
},
body: JSON.stringify(payload),
}
);
const commitResp = await response.json();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment