17
17
with :
18
18
node-version : ' 18'
19
19
- name : Install dependencies
20
- run : npm install @octokit/core
20
+ run : npm install @octokit/core
21
21
- name : Adding Issues
22
22
uses : actions/github-script@v6
23
23
env :
@@ -54,14 +54,32 @@ jobs:
54
54
console.log("workMeetings:" + JSON.stringify(workMeetings));
55
55
56
56
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));
61
57
62
58
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;
65
83
console.log("Discussions to add:" + JSON.stringify(discussions));
66
84
67
85
try {
84
102
85
103
// Loop through discussions to add them to the agenda
86
104
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;
90
108
let search = parseInt(JSON.stringify(body).search(url));
91
109
if (search === -1) {
92
110
let startIndex = parseInt(JSON.stringify(body.indexOf(placeholder)))
@@ -103,15 +121,12 @@ jobs:
103
121
console.log(`PATCH /repos/${process.env.OWNER}/${process.env.REPO}/issues/${workMeetings[0].number}`);
104
122
105
123
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',
109
127
})
110
128
}
111
129
}
112
-
113
-
114
-
115
130
catch (err) {
116
131
console.error("Error:"+err.message);
117
132
console.log("There is no OCWM available");
0 commit comments