Skip to content

Commit f9eb580

Browse files
committed
fix(docs): look up open issues on main builds for Renovate docs (#39801)
We're currently always skipping the detection of open bugs/features, so even though [0] introduced authentication to GitHub, this didn't actually lead to the lookup when running in CI. If we're not running in Renovate's CI build (i.e. as part of the release process) or the docs site's CI build (as part of post-release operations) we should continue to skip the build, when running in CI. This also makes it clearer with a WARN log line to explain why this is being skipped. This is a re-apply of ae46c57, as well as making sure that the `GITHUB_TOKEN` is explicitly passed as `extraEnv`, otherwise we see i.e. ``` ERROR: Error getting query results "err": { "cmd": "/bin/sh -c gh issue list --json \"title,number,url,labels\" --search \"type:Bug\" --limit 1000", "stderr": "gh: To use GitHub CLI in automation, set the GH_TOKEN environment variable.\n", "stdout": "", "options": { "encoding": "utf-8", "env": ["CI", "HOME", "PATH", "LANG"], "maxBuffer": 10485760, "timeout": 900000 }, "exitCode": 4, "name": "ExecError", "message": "Command failed: gh issue list ...\ngh: To use GitHub CLI in automation, set the GH_TOKEN environment variable.\n", "stack": "ExecError: Command failed: gh issue list ...\ngh: To use GitHub CLI in automation, set the GH_TOKEN environment variable.\n\n at ..." } ``` As we can see, the `env` isn't automagically picking up the `GITHUB_TOKEN`, so we should explicitly pass it. [0]: renovatebot/renovatebot.github.io#746
1 parent 83e0b97 commit f9eb580

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tools/docs/github-query-items.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ async function getIssuesByIssueType(
4646
issueType: 'Bug' | 'Feature',
4747
): Promise<ItemsEntity[]> {
4848
const command = `gh issue list --json "title,number,url,labels" --search "type:${issueType}" --limit 1000`;
49-
const execRes = await exec(command);
49+
const execRes = await exec(command, {
50+
extraEnv: {
51+
GITHUB_TOKEN: process.env.GITHUB_TOKEN,
52+
},
53+
});
5054
const res = GhOutput.safeParse(JSON.parse(execRes.stdout));
5155
if (res.error) {
5256
throw res.error;
@@ -78,7 +82,20 @@ export async function getOpenGitHubItems(): Promise<RenovateOpenItems> {
7882
}
7983

8084
if (process.env.CI) {
81-
return result;
85+
if (
86+
process.env.GITHUB_REF === 'main' &&
87+
process.env.GITHUB_REPOSITORY !== 'renovatebot/renovatebot.github.io' &&
88+
process.env.GITHUB_REPOSITORY !== 'renovatebot/renovate'
89+
) {
90+
logger.warn(
91+
{
92+
repository: process.env.GITHUB_REPOSITORY,
93+
ref: process.env.GITHUB_REF,
94+
},
95+
"Skipping collection of open GitHub Issues, as we're running CI on a non-HEAD branch of Renovate or its docs site",
96+
);
97+
return result;
98+
}
8299
}
83100

84101
try {

0 commit comments

Comments
 (0)