diff --git a/.github/GithubAPI.js b/.github/GithubAPI.js index f8adf9d..ccecacb 100644 --- a/.github/GithubAPI.js +++ b/.github/GithubAPI.js @@ -1,31 +1,9 @@ -const axios = require("axios"); - module.exports = class GithubAPI { constructor(owner, github) { this.owner = owner; this.github = github; } - async query(query, variables) { - try { - const response = await this.github.graphql( - query, - variables - ); - - console.log("Response", response); - - if (response.data.errors) { - throw new Error(JSON.stringify(response.data.errors, null, 2)); - } - - return response.data; - } catch (error) { - console.error(error); - throw error; - } - } - async getSourceAndTargetProjects({ sourceNumber, targetNumber }) { const projectSubquery = ` id @@ -45,7 +23,7 @@ module.exports = class GithubAPI { `; const query = ` query getSourceAndTargetProjectsIds($owner: String!, $source: Int!, $target: Int!) { - user (login: $owner) { + organization (login: $owner) { source: projectV2(number: $source) { ${projectSubquery} } @@ -56,7 +34,7 @@ module.exports = class GithubAPI { } `; - const response = await this.query(query, { + const response = await this.github.graphql(query, { owner: this.owner, source: sourceNumber, target: targetNumber, @@ -134,7 +112,7 @@ module.exports = class GithubAPI { `; const _getProjectItems = async (cursor = null, items = []) => { - const response = await this.query(query, { + const response = await this.github.graphql(query, { projectId, cursor }); @@ -174,7 +152,7 @@ module.exports = class GithubAPI { const batch = items.slice(i, i + BATCH_SIZE); await Promise.all(batch.map(async item => { - await this.query(query, { + await this.github.graphql(query, { projectId: item.projectId, itemId: item.projectItemId, fieldId: item.fieldId, diff --git a/.github/workflows/sync_kds_roadmap_statuses.yml b/.github/workflows/sync_kds_roadmap_statuses.yml index f7582c8..7cd24f1 100644 --- a/.github/workflows/sync_kds_roadmap_statuses.yml +++ b/.github/workflows/sync_kds_roadmap_statuses.yml @@ -19,9 +19,6 @@ jobs: with: node-version: '18' - - name: Install axios - run: npm install axios - - uses: tibdex/github-app-token@v1 id: generate-token with: