diff --git a/.github/GithubAPI.js b/.github/GithubAPI.js index b63677b..389a463 100644 --- a/.github/GithubAPI.js +++ b/.github/GithubAPI.js @@ -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); @@ -19,6 +19,7 @@ module.exports = class GithubAPI { } }); + console.log("response", response); if (response.data.errors) { throw new Error(JSON.stringify(response.data.errors, null, 2)); } @@ -48,13 +49,13 @@ 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 + } } } } @@ -62,8 +63,6 @@ module.exports = class GithubAPI { const response = await this.query(query, { owner: this.owner, - source: sourceNumber, - target: targetNumber, }); const { source, target } = response.data.organization; diff --git a/.github/githubUtils.js b/.github/githubUtils.js index 257f4c5..0c7178a 100644 --- a/.github/githubUtils.js +++ b/.github/githubUtils.js @@ -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) => { @@ -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); diff --git a/.github/workflows/sync_kds_roadmap_statuses.yml b/.github/workflows/sync_kds_roadmap_statuses.yml index 7e81007..be3cba3 100644 --- a/.github/workflows/sync_kds_roadmap_statuses.yml +++ b/.github/workflows/sync_kds_roadmap_statuses.yml @@ -38,4 +38,4 @@ jobs: script: | console.log("github", github); const { synchronizeProjectsStatuses } = require('./.github/githubUtils.js'); - synchronizeProjectsStatuses(github); + synchronizeProjectsStatuses(context, github);