Repository: semantic-release/github (js)

Issue:
Invalid GQL Query in `buildAssociatedPRsQuery` when commits/shas empty
During the upgrade to v10.0.7 which introduced GraphQL to the `success` lifecycle method, we've noticed an increase in errors in our CI pipeline and have narrowed it down to an invalid GQL Query in  `buildAssociatedPRsQuery` as a result of the `shas` variable being empty (`context.commits`). 

This may be specific to our workflow with an additional plugin, however we have the ability to force semantic release to publish a new version, which results in `context.commits` being empty and therefore a GQL query gets generated as below:

```
#graphql
query getAssociatedPRs($owner: String!, $repo: String!) {
      repository(owner: $owner, name: $repo) {
      }
 }
```

Resulting in:

```
11:56:33 GraphqlResponseError: Request failed due to following response errors:
11:56:33  - Parse error on "}" (RCURLY) at [5, 7]
```

It would be nice if the changes made in be394cfb9190b9cb8961e7a9155f39eb00cbde8b would handle empty `context.commits` as per the previous implementation.

Pull request description:
fix: invalid GraphQL query generated when no release commits are found
This Pull request improves the conditions required to execute the search for and comment/label Pull Requests and Issues associated to a release commits in the `success` lifecycle, ensuring that the operation factors in cases where `context.commits` is empty.

### Related Issue

Fixes #871 

Patch:
diff --git a/lib/success.js b/lib/success.js
index 49ad22e..8c2d458 100644
--- a/lib/success.js
+++ b/lib/success.js
@@ -54,7 +54,10 @@ export default async function success(pluginConfig, context, { Octokit }) {
 
   const errors = [];
 
-  if (successComment === false) {
+  if (successComment === false || isEmpty(commits)) {
+    if (isEmpty(commits)) {
+      logger.log("No commits found in release");
+    }
     logger.log("Skip commenting on issues and pull requests.");
   } else {
     const parser = issueParser(


Test patch:
diff --git a/test/success.test.js b/test/success.test.js
index 5ef815a..8d87dcc 100644
--- a/test/success.test.js
+++ b/test/success.test.js
@@ -806,6 +806,61 @@ test("Do not add comment and labels if no PR is associated with release commits"
   t.true(fetch.done());
 });
 
+test("Do not add comment and labels if no commits is found for release", async (t) => {
+  const owner = "test_user";
+  const repo = "test_repo";
+  const env = { GITHUB_TOKEN: "github_token" };
+  const failTitle = "The automated release is failing 🚨";
+  const pluginConfig = { failTitle };
+  const options = {
+    branch: "master",
+    repositoryUrl: `https://github.com/${owner}/${repo}.git`,
+  };
+  const commits = [];
+  const nextRelease = { version: "1.1.0" };
+  const releases = [
+    { name: "GitHub release", url: "https://github.com/release" },
+  ];
+
+  const fetch = fetchMock
+    .sandbox()
+    .getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
+      full_name: `${owner}/${repo}`,
+    })
+    .getOnce(
+      `https://api.github.local/search/issues?q=${encodeURIComponent(
+        "in:title",
+      )}+${encodeURIComponent(`repo:${owner}/${repo}`)}+${encodeURIComponent(
+        "type:issue",
+      )}+${encodeURIComponent("state:open")}+${encodeURIComponent(failTitle)}`,
+      { items: [] },
+    );
+
+  await success(
+    pluginConfig,
+    {
+      env,
+      options,
+      commits,
+      nextRelease,
+      releases,
+      logger: t.context.logger,
+    },
+    {
+      Octokit: TestOctokit.defaults((options) => ({
+        ...options,
+        request: { ...options.request, fetch },
+      })),
+    },
+  );
+
+  t.true(fetch.done());
+  t.true(t.context.log.calledWith("No commits found in release"));
+  t.true(
+    t.context.log.calledWith("Skip commenting on issues and pull requests."),
+  );
+});
+
 test("Do not add comment and labels to PR/issues from other repo", async (t) => {
   const owner = "test_user";
   const repo = "test_repo";