1
我正在使用npm GitHub API。使用GitHub API编辑和添加提交消息到文件
而且我有四块数据。
- 的裁判我想更新
- 的路径,我想更新
- 新内容的文件,我想在这个文件
- 提交信息我想为这个文件编辑
此外,我可以验证API,并有权访问此回购。
我该如何编辑这个文件并推送这个提交?
const GitHub = require('github-api')
const gh = new GitHub({
token: config.app.git_token,
}, githubUrl)
const repo = gh.getRepo(config.app.repoOwner, config.app.repoName)
repo.getRef(`heads/${config.app.repoBranch}`).then((response) => {
const ref = response.data.object.sha
const path = 'README.md'
const content = '#Foo Bar\nthis is foo bar'
const message = 'make readme foo bar'
console.log('ref to the file i want to update')
console.log(ref)
console.log('path to the file i want to update')
console.log(path)
console.log('contents i now want in this file')
console.log(content)
console.log('commit message message')
console.log(message)
// how do i now edit and add a commit to this remote file?
})
我一直在使用.commit尝试,但到目前为止,还没有得到它的工作,我不知道如何来生成正确的PARAMS该函数调用。