Skip to content

Fix issue collector adding graphql support #478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
29ce73e
Better management of 404 errors
benjagm Sep 11, 2023
b0f9726
Improve try catch management
benjagm Sep 11, 2023
515b22f
Pre-declare destination arrays
benjagm Sep 11, 2023
555d141
Adding missing parentheses
benjagm Sep 11, 2023
b7fe256
Improve formatting
benjagm Sep 11, 2023
cb81f2a
Update arrays management
benjagm Sep 11, 2023
c28b69c
Use graphql to retrieve discussions
benjagm Sep 11, 2023
1ad6bad
Code refactor
benjagm Sep 11, 2023
6359af0
Yaml formatting error
benjagm Sep 11, 2023
5062e28
Another refactor
benjagm Sep 11, 2023
8f29344
Full refactor to previous version
benjagm Sep 11, 2023
a3f2a1a
Another version
benjagm Sep 11, 2023
2aa91a9
new graphql implementation
benjagm Sep 11, 2023
298b67c
add fetch to graphql
benjagm Sep 11, 2023
8c98373
Testing something new
benjagm Sep 11, 2023
c96503c
Remove unnecessary dependency
benjagm Sep 11, 2023
86742da
more changes. Filter and specific fields to fetch
benjagm Sep 11, 2023
249bb60
retrieve author
benjagm Sep 11, 2023
9d3d977
generic search
benjagm Sep 11, 2023
97c7b86
unnecessary line removed
benjagm Sep 11, 2023
7a91684
test line
benjagm Sep 11, 2023
ea0ea0d
var name
benjagm Sep 11, 2023
72b8261
adding logs
benjagm Sep 11, 2023
80375c1
Better graphql query
benjagm Sep 11, 2023
1ea5741
Missing curly brace added
benjagm Sep 11, 2023
dd00788
Add more logs
benjagm Sep 11, 2023
6ce9e28
Change how to load the graphql response.
benjagm Sep 11, 2023
2086ea6
Another alternative
benjagm Sep 11, 2023
9a37e96
More changes
benjagm Sep 11, 2023
d4ba482
more changes
benjagm Sep 11, 2023
b1555fa
Multiple tests
benjagm Sep 11, 2023
546fad9
Remove internal try catches
benjagm Sep 11, 2023
5e7d8bc
Add resourcepath
benjagm Sep 11, 2023
2575379
Completing the url
benjagm Sep 11, 2023
fd4c35d
Remove unnecessary comment
benjagm Sep 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
Binary file added .github/.DS_Store
Binary file not shown.
47 changes: 31 additions & 16 deletions .github/workflows/ocwm-issue-collector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
node-version: '18'
- name: Install dependencies
run: npm install @octokit/core
run: npm install @octokit/core
- name: Adding Issues
uses: actions/github-script@v6
env:
Expand Down Expand Up @@ -54,14 +54,32 @@ jobs:
console.log("workMeetings:" + JSON.stringify(workMeetings));

for (let r = 0; r < repositories.length; r++) {
console.log(`GET /repos/${process.env.OWNER}/${repositories[r]}/issues?labels=${appendLabel}`);
const { data: items2add } = await mygithub.request(`GET /repos/${process.env.OWNER}/${repositories[r]}/issues?labels=${appendLabel}`, {
});
console.log("Issues to add:" + JSON.stringify(items2add));


const { data: discussions } = await mygithub.request(`GET /repos/${process.env.OWNER}/${repositories[r]}/discussions?labels=${appendLabel}`, {
});
const { data: items2add } = await mygithub.request(`GET /repos/${process.env.OWNER}/${repositories[r]}/issues?labels=${appendLabel}`);
console.log("Issues to add:" + JSON.stringify(items2add));

const query = `
query {
search(query: "repo:${process.env.OWNER}/${repositories[r]} is:open label:${appendLabel}", type: DISCUSSION, first: 5) {
edges {
node {
... on Discussion {
title
body
resourcePath
author {
login
}
}
}
}
}
}`;
const response = await mygithub.graphql(query, {});
console.log("Response:" + JSON.stringify(response));

const discussions = response.search.edges;
console.log("Discussions to add:" + JSON.stringify(discussions));

try {
Expand All @@ -84,9 +102,9 @@ jobs:

// Loop through discussions to add them to the agenda
for (let i = 0; i < discussions.length; i++) {
let url = discussions[i].html_url;
let author = "@" + discussions[i].user.login;
let title = discussions[i].title;
let url = "https://github.com/" + discussions[i].node.resourcePath;
let author = "@" + discussions[i].node.author.login;
let title = discussions[i].node.title;
let search = parseInt(JSON.stringify(body).search(url));
if (search === -1) {
let startIndex = parseInt(JSON.stringify(body.indexOf(placeholder)))
Expand All @@ -103,15 +121,12 @@ jobs:
console.log(`PATCH /repos/${process.env.OWNER}/${process.env.REPO}/issues/${workMeetings[0].number}`);

await mygithub.request(`PATCH /repos/${process.env.OWNER}/${process.env.REPO}/issues/${workMeetings[0].number}`, {
body: parsed,
milestone: null,
state: 'open',
body: parsed,
milestone: null,
state: 'open',
})
}
}



catch (err) {
console.error("Error:"+err.message);
console.log("There is no OCWM available");
Expand Down