Upload a file using the GraphQL and GitHub A.P.I. in JavaScript #38279
Unanswered
catafest-work
asked this question in
API and Webhooks
Replies: 3 comments
-
I think can be done with createCommitOnBranch but the documentation is lacking.. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Here's a past discussion that might provide some clarity. Hope it helps! |
Beta Was this translation helpful? Give feedback.
0 replies
-
query GetBranch{
repository (name: "catafest-work", owner: "catafest-work") {
ref (qualifiedName: "main") {
target {
... on Commit {
history(first: 1) {
nodes {
oid
}
}
}
}
}
}
} {
"data": {
"repository": {
"ref": {
"target": {
"history": {
"nodes": [
{
"oid": "0ae81c22379ed54e74f8cdbb118c6cede783bc6a"
}
]
}
}
}
}
}
}
mutation ($contents: Base64String!, $oid: GitObjectID!){
createCommitOnBranch (input: {
branch : {
repositoryNameWithOwner: "catafest-work/catafest-work"
branchName: "main"
# Replace main with another name to create a new branch from the last commit of the main branch.
# Or it will push changes to the main branch.
}
message: {
headline: "feat: Commit through Graphql"
}
fileChanges: {
additions: [
{
path: "docs/README.md"
contents: $contents
}
],
deletions: [
{
path: "README.md"
}
]
}
expectedHeadOid: $oid
}) {
commit {
commitUrl
}
}
} Returns commit URL. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to upload a file to my repo using the GraphQL and GitHub A.P.I. in JavaScript.
I search on web and on documentation but I don't find a good way to solve it.
Any idea?
Beta Was this translation helpful? Give feedback.
All reactions