fix: replace `searchAPI` usage with `GraphQL` in `findSRIssue` util
This Pull request replaces the usage of the troublesome 😉 GitHub SearchAPI as primary logic in the findSRIssue with graphql. It relegates the searchAPI consumption to a fallback logic that will be removed in a future release.
The GraphQL functionality performs its search for Semantic Release Issue by querying for Issues on a repository with specific filter, in our case we use a label in the filter. This means that the PR introduces changes to the way we "create" and "find" Sematic Release issues in the fail and success script.
Changes Made:
-
Introduced an opinionated label for Semantic Release failing release issues in form of a constant
RELEASE_FAIL_LABEL -
Concatenated the
RELEASE_FAIL_LABELto thelabelparam on creation of semantic release failing issue in thefailscript; this means the our opinionated label gets added to the failing release issue regardless of the plugincontext.labelconfiguration value (which is eithersemantic-release,CUSTOM_LABELorfalse)const newIssue = { owner, repo, title: failTitle, body: `${body}\n\n${ISSUE_ID}`, labels: (labels || []).concat([RELEASE_FAIL_LABEL]), // 👈 👈 👈 👈 HERE assignees, }; -
Introduced the GraphQL Query that the appropriated
filterand passed into it is thelabelsfilter withcontext.labelconfiguration concatenated with our opinionatedRELEASE_FAIL_LABELas value;const { repository: { issues: { nodes: issueNodes }, }, } = await octokit.graphql(loadGetSRIssuesQuery, { owner, repo, filter: { labels: (labels || []).concat([RELEASE_FAIL_LABEL]), // 👈 👈 👈 👈 HERE }, });
Related Issue
Fixes #867