我有一个 GitHub 操作可以评估某些内容,然后使用结果创建状态检查。
setup是评估linting结果也是结果(对所有信息进行不同的状态检查)。这样做是因为默认状态检查只是日志,但如果我创建第二个,我可以使用 Markdown 对其进行格式化。
我遇到的问题是,当对同一提交执行操作时(因为通过更改标题、审阅者等修改了拉取请求),该操作将再次执行,这是有意的,但会创建第二次setup检查,但不会消失。这将累积我所做的修改。
linting相反,旧的状态检查将被新的状态检查取代,所以我对此没有任何问题。
setup一旦完成,有没有办法隐藏支票?或者完全隐藏它?我更愿意在它运行时显示它,但是一旦它完成,它应该隐藏自己以保持 PR 干净。
在具有repo和用户授权范围的GitHub API v3 中,我可以使用GET /user/orgs(https://developer.github.com/v3/orgs/#list-organizations-for-the-authenticated-user,使用 Octokit REST JS,octokit.orgs.listForAuthenticatedUser()) 并且对于每个组织,获取我可以访问的存储库,GET /orgs/:org/repos( https://developer.github.com/v3/repos/#list-organization-repositories,与 Octokit octokit.repos.listForOrg({ org: orgs.data[i].login }))。
但是,使用相同的身份验证范围(用户和存储库),运行此 Graphql 查询
query getOrgsRepos {
viewer {
organizations(first: 10) {
nodes {
repositories(first: 10) {
nodes {
name
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
退货
{
"data": {
"viewer": {
"organizations": {
"nodes": []
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
Graphql Explorer 结果(https://developer.github.com/v4/explorer/),但在我的 JS authed(用户和repo范围)应用程序上运行返回相同的空结果 …
我们使用@octokit/rest客户端来获取拉取请求的所有评论:
client.pulls
.listComments({
owner,
repo,
pull_number: 34,
per_page: 100,
})
.then((result) => {
console.log(result.data.length);
console.log(result.data[0]);
});
Run Code Online (Sandbox Code Playgroud)
如果我们可以只列出未解决的评论怎么办?数据中似乎没有属性表明某人是否已解决该评论。
我创建了一个新的 GitHub 应用程序,我正在尝试从 Node.js 进行身份验证。例如,我是 GitHub Apps 的新手,我不知道“installationId”应该是什么。那是应用ID吗?
我使用私钥成功获取了令牌,但是当我尝试使用 API 时,我收到来自 Node 和 curl 的错误。
import { createAppAuth } from '@octokit/auth-app';
import { request } from '@octokit/request';
const privateKey = fs.readFileSync(__dirname + 'file.pem');
const auth = createAppAuth({
id: 1,
privateKey,
installationId: 12345,
clientId: 'xxx.xxxxxx',
clientSecret: 'xxxxxx',
});
const appAuthentication = await auth({ type: 'app' });
console.log(`Git repo token: ` + appAuthentication.token);
const result = await request('GET /orgs/:org/repos', {
headers: {
authorization: 'token ' + appAuthentication.token,
},
org: 'orgname',
type: 'public', …Run Code Online (Sandbox Code Playgroud) 我在做什么?
我正在将 Vite 用于我的 React 应用程序。我正在导入 Octokit 并像这样绑定它:
import { Octokit } from "octokit";
const githubToken = import.meta.env.REACT_APP_GITHUB_TOKEN;
const octokit = new Octokit({auth: githubToken});
Run Code Online (Sandbox Code Playgroud)
我希望这个功能能够正常运行。就像这样,我希望使用octokit完美的方式提出请求。
我正在经历什么?
或者至少,它是这样开始的:Module "stream" has been externalized for browser compatibility and cannot be accessed in client code.
octokit-js ×5
github ×3
github-api ×3
octokit ×3
github-app ×1
graphql ×1
node.js ×1
pull-request ×1
reactjs ×1
vite ×1