Skip to content

Commit ba4af50

Browse files
authored
Merge pull request #478 from benjagm/main
Fix issue collector adding graphql support
2 parents 4f6a8b7 + fd4c35d commit ba4af50

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.github/.DS_Store

6 KB
Binary file not shown.

.github/workflows/ocwm-issue-collector.yml

+31-16
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
node-version: '18'
1919
- name: Install dependencies
20-
run: npm install @octokit/core
20+
run: npm install @octokit/core
2121
- name: Adding Issues
2222
uses: actions/github-script@v6
2323
env:
@@ -54,14 +54,32 @@ jobs:
5454
console.log("workMeetings:" + JSON.stringify(workMeetings));
5555
5656
for (let r = 0; r < repositories.length; r++) {
57-
console.log(`GET /repos/${process.env.OWNER}/${repositories[r]}/issues?labels=${appendLabel}`);
58-
const { data: items2add } = await mygithub.request(`GET /repos/${process.env.OWNER}/${repositories[r]}/issues?labels=${appendLabel}`, {
59-
});
60-
console.log("Issues to add:" + JSON.stringify(items2add));
6157
6258
63-
const { data: discussions } = await mygithub.request(`GET /repos/${process.env.OWNER}/${repositories[r]}/discussions?labels=${appendLabel}`, {
64-
});
59+
const { data: items2add } = await mygithub.request(`GET /repos/${process.env.OWNER}/${repositories[r]}/issues?labels=${appendLabel}`);
60+
console.log("Issues to add:" + JSON.stringify(items2add));
61+
62+
const query = `
63+
query {
64+
search(query: "repo:${process.env.OWNER}/${repositories[r]} is:open label:${appendLabel}", type: DISCUSSION, first: 5) {
65+
edges {
66+
node {
67+
... on Discussion {
68+
title
69+
body
70+
resourcePath
71+
author {
72+
login
73+
}
74+
}
75+
}
76+
}
77+
}
78+
}`;
79+
const response = await mygithub.graphql(query, {});
80+
console.log("Response:" + JSON.stringify(response));
81+
82+
const discussions = response.search.edges;
6583
console.log("Discussions to add:" + JSON.stringify(discussions));
6684
6785
try {
@@ -84,9 +102,9 @@ jobs:
84102
85103
// Loop through discussions to add them to the agenda
86104
for (let i = 0; i < discussions.length; i++) {
87-
let url = discussions[i].html_url;
88-
let author = "@" + discussions[i].user.login;
89-
let title = discussions[i].title;
105+
let url = "https://github.com/" + discussions[i].node.resourcePath;
106+
let author = "@" + discussions[i].node.author.login;
107+
let title = discussions[i].node.title;
90108
let search = parseInt(JSON.stringify(body).search(url));
91109
if (search === -1) {
92110
let startIndex = parseInt(JSON.stringify(body.indexOf(placeholder)))
@@ -103,15 +121,12 @@ jobs:
103121
console.log(`PATCH /repos/${process.env.OWNER}/${process.env.REPO}/issues/${workMeetings[0].number}`);
104122
105123
await mygithub.request(`PATCH /repos/${process.env.OWNER}/${process.env.REPO}/issues/${workMeetings[0].number}`, {
106-
body: parsed,
107-
milestone: null,
108-
state: 'open',
124+
body: parsed,
125+
milestone: null,
126+
state: 'open',
109127
})
110128
}
111129
}
112-
113-
114-
115130
catch (err) {
116131
console.error("Error:"+err.message);
117132
console.log("There is no OCWM available");

0 commit comments

Comments
 (0)