mirror of
https://github.com/logos-messaging/bounties.git
synced 2026-01-02 12:53:07 +00:00
set up Jenkinsfile and nodejs script to fetch open issues
This commit is contained in:
parent
de93f2beb1
commit
8b23228b55
33
Jenkinsfile
vendored
Normal file
33
Jenkinsfile
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
pipeline {
|
||||||
|
agent { label 'linux' }
|
||||||
|
|
||||||
|
options {
|
||||||
|
disableConcurrentBuilds()
|
||||||
|
/* manage how many builds we keep */
|
||||||
|
buildDiscarder(logRotator(
|
||||||
|
numToKeepStr: '20',
|
||||||
|
daysToKeepStr: '30',
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
GIT_COMMITTER_NAME = 'status-im-auto'
|
||||||
|
GIT_COMMITTER_EMAIL = 'auto@status.im'
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
sh 'mdbook build'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Publish') {
|
||||||
|
steps {
|
||||||
|
sshagent(credentials: ['status-im-auto-ssh']) {
|
||||||
|
sh "ghp-import -p book"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
126
script.js
Normal file
126
script.js
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
const https = require("https");
|
||||||
|
|
||||||
|
if (process.argv.length < 4) {
|
||||||
|
console.error("Usage: node script.js [owner] [repo]");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const owner = process.argv[2];
|
||||||
|
const repo = process.argv[3];
|
||||||
|
|
||||||
|
const query = `
|
||||||
|
{
|
||||||
|
repository(owner: "${owner}", name: "${repo}") {
|
||||||
|
issues(first: 100, states: OPEN) {
|
||||||
|
nodes {
|
||||||
|
id
|
||||||
|
title
|
||||||
|
url
|
||||||
|
author {
|
||||||
|
login
|
||||||
|
avatarUrl
|
||||||
|
}
|
||||||
|
labels(first: 10) {
|
||||||
|
nodes {
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
commentCount: comments {
|
||||||
|
totalCount
|
||||||
|
}
|
||||||
|
commentsDetailed: comments(first: 10) {
|
||||||
|
nodes {
|
||||||
|
id
|
||||||
|
author {
|
||||||
|
login
|
||||||
|
}
|
||||||
|
body
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assignees(first: 10) {
|
||||||
|
nodes {
|
||||||
|
login
|
||||||
|
avatarUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
milestone {
|
||||||
|
title
|
||||||
|
}
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
projectCards(first: 10) {
|
||||||
|
nodes {
|
||||||
|
project {
|
||||||
|
name
|
||||||
|
url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
hostname: "api.github.com",
|
||||||
|
path: "/graphql",
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"User-Agent": "NodeJS-Script",
|
||||||
|
Authorization: "bearer YOUR_GITHUB_TOKEN", // Note: Using bearer for GraphQL
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const req = https.request(options, (res) => {
|
||||||
|
let data = "";
|
||||||
|
|
||||||
|
res.on("data", (chunk) => {
|
||||||
|
data += chunk;
|
||||||
|
});
|
||||||
|
|
||||||
|
res.on("end", () => {
|
||||||
|
try {
|
||||||
|
const response = JSON.parse(data);
|
||||||
|
console.log("Response:", response);
|
||||||
|
const rawIssues = response.data?.repository?.issues.nodes;
|
||||||
|
|
||||||
|
const extractedIssues = rawIssues.map((issue) => ({
|
||||||
|
id: issue.id,
|
||||||
|
title: issue.title,
|
||||||
|
url: issue.url,
|
||||||
|
user: {
|
||||||
|
login: issue.author.login,
|
||||||
|
avatarUrl: issue.author.avatarUrl,
|
||||||
|
},
|
||||||
|
labels: issue.labels.nodes.map((label) => label.name),
|
||||||
|
commentCount: issue.commentCount.totalCount,
|
||||||
|
comments: issue.commentsDetailed.nodes.map(comment => ({
|
||||||
|
id: comment.id,
|
||||||
|
author: comment.author.login,
|
||||||
|
body: comment.body,
|
||||||
|
createdAt: comment.createdAt
|
||||||
|
})),
|
||||||
|
assignees: issue.assignees.nodes,
|
||||||
|
milestone: issue.milestone ? issue.milestone.title : null,
|
||||||
|
created_at: issue.createdAt,
|
||||||
|
updated_at: issue.updatedAt,
|
||||||
|
projects: issue.projectCards.nodes.map((card) => card.project),
|
||||||
|
}));
|
||||||
|
|
||||||
|
console.log(JSON.stringify(extractedIssues, null, 2));
|
||||||
|
return extractedIssues
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to parse response:", error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
req.on("error", (error) => {
|
||||||
|
console.error(`Got an error: ${error.message}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
req.write(JSON.stringify({ query }));
|
||||||
|
req.end();
|
||||||
Loading…
x
Reference in New Issue
Block a user