This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 0c998b8633 Fix autolabel workflow label search
0c998b8633 is described below
commit 0c998b86330dc1fd138ae7a6cd0718b9bba8bea8
Author: James Netherton <[email protected]>
AuthorDate: Fri Aug 9 12:12:36 2024 +0100
Fix autolabel workflow label search
---
.github/workflows/label-issue.yaml | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/.github/workflows/label-issue.yaml
b/.github/workflows/label-issue.yaml
index ae2fa011e7..d14a7988a3 100644
--- a/.github/workflows/label-issue.yaml
+++ b/.github/workflows/label-issue.yaml
@@ -134,31 +134,17 @@ jobs:
}
}
- // Strip the / prefix as it seems to break GraphQL searches
- const sanitizedLabels = Array.from(labels).map(label => {
- const parts = label.split('/');
- return parts.length > 1 ? parts[1] : parts[0];
- });
-
// Check to see if labels already exist, and if not, create them
so we can set the color
- const labelQuery = `{
- repository(owner: "${context.repo.owner}", name:
"${context.repo.repo}") {
- labels(first: 50, query: "name: ${sanitizedLabels.join(' ||
')}") {
- nodes {
- name
- }
- }
- }
- }`;
-
- labelQueryResults = await github.graphql(labelQuery);
-
- if (labelQueryResults && labelQueryResults.repository.labels) {
- const existingLabels =
labelQueryResults.repository.labels.nodes.map(node => node.name);
+ const existingLabels = await github.paginate(
+ `GET /repos/${context.repo.owner}/${context.repo.repo}/labels`,
+ { owner: context.repo.owner, name: context.repo.repo },
+ (response) => response.data.map((label) => label.name)
+ );
+ if (existingLabels) {
for (let label of labels) {
if (!existingLabels.includes(label)) {
- labelColor = 'ededed';
+ let labelColor = 'ededed';
if (label.startsWith("area/")) {
labelColor = '283482';
}