Skip to content

Commit

Permalink
Try getting all projects
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVelezLl committed Jan 8, 2025
1 parent 00584ac commit cbd9274
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
17 changes: 8 additions & 9 deletions .github/GithubAPI.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const axios = require("axios");

module.exports = class GithubAPI {
constructor(owner) {
constructor(owner, github) {
this.url = 'https://api.github.com/graphql';
this.token = process.env.GITHUB_TOKEN;
console.log("Is there a github token?", !!this.token);
Expand All @@ -19,6 +19,7 @@ module.exports = class GithubAPI {
}
});

console.log("response", response.data.data.organization);
if (response.data.errors) {
throw new Error(JSON.stringify(response.data.errors, null, 2));
}
Expand Down Expand Up @@ -48,22 +49,20 @@ module.exports = class GithubAPI {
}
`;
const query = `
query getSourceAndTargetProjectsIds($owner: String!, $source: Int!, $target: Int!) {
query getSourceAndTargetProjectsIds($owner: String!) {
organization (login: $owner) {
source: projectV2(number: $source) {
${projectSubquery}
}
target: projectV2(number: $target) {
${projectSubquery}
projectsV2(first: 20) {
nodes {
id
title
}
}
}
}
`;

const response = await this.query(query, {
owner: this.owner,
source: sourceNumber,
target: targetNumber,
});

const { source, target } = response.data.organization;
Expand Down
4 changes: 2 additions & 2 deletions .github/githubUtils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const GithubAPI = require('./GithubAPI');

const synchronizeProjectsStatuses = async (github) => {
const synchronizeProjectsStatuses = async (context, github) => {
const sourceNumber = 15; //"Iteration backlog";
const targetNumber = 29; // KDS Roadmap
const getTargetStatus = (sourceStatus) => {
Expand All @@ -18,7 +18,7 @@ const synchronizeProjectsStatuses = async (github) => {
return targetStatus ? statusMap[targetStatus] : "BACKLOG";
}

const githubAPI = new GithubAPI("LearningEquality", github);
const githubAPI = new GithubAPI(context.repo.owner, github);
const { sourceProject, targetProject } = await githubAPI.getSourceAndTargetProjects({ sourceNumber, targetNumber });

console.log("sourceName", sourceNumber);
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync_kds_roadmap_statuses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
script: |
console.log("github", github);
const { synchronizeProjectsStatuses } = require('./.github/githubUtils.js');
synchronizeProjectsStatuses(github);
synchronizeProjectsStatuses(context, github);

0 comments on commit cbd9274

Please sign in to comment.