Skip to content

Commit

Permalink
fix: update GitHub API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
dessant committed Jul 9, 2021
1 parent f3414b1 commit 7c35b1c
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ class App {
threadData.user.login
);

await this.client.issues.createComment({...issue, body: commentBody});
await this.client.rest.issues.createComment({
...issue,
body: commentBody
});
}
});
}
Expand All @@ -81,7 +84,7 @@ class App {

if (newLabels.length) {
core.debug('Labeling');
await this.client.issues.addLabels({
await this.client.rest.issues.addLabels({
...issue,
labels: newLabels
});
Expand All @@ -96,7 +99,7 @@ class App {

for (const label of matchingLabels) {
core.debug('Unlabeling');
await this.client.issues.removeLabel({
await this.client.rest.issues.removeLabel({
...issue,
name: label
});
Expand All @@ -105,12 +108,12 @@ class App {

if (actions.reopen && threadData.state === 'closed' && !threadData.merged) {
core.debug('Reopening');
await this.client.issues.update({...issue, state: 'open'});
await this.client.rest.issues.update({...issue, state: 'open'});
}

if (actions.close && threadData.state === 'open') {
core.debug('Closing');
await this.client.issues.update({...issue, state: 'closed'});
await this.client.rest.issues.update({...issue, state: 'closed'});
}

if (actions.lock && !threadData.locked) {
Expand All @@ -125,12 +128,12 @@ class App {
}
});
}
await this.client.issues.lock(params);
await this.client.rest.issues.lock(params);
}

if (actions.unlock && threadData.locked) {
core.debug('Unlocking');
await this.client.issues.unlock(issue);
await this.client.rest.issues.unlock(issue);
}
}

Expand All @@ -155,15 +158,15 @@ class App {
async ensureUnlock(issue, lock, action) {
if (lock.active) {
if (!lock.hasOwnProperty('reason')) {
const {data: issueData} = await this.client.issues.get({
const {data: issueData} = await this.client.rest.issues.get({
...issue,
headers: {
Accept: 'application/vnd.github.sailor-v-preview+json'
}
});
lock.reason = issueData.active_lock_reason;
}
await this.client.issues.unlock(issue);
await this.client.rest.issues.unlock(issue);

let actionError;
try {
Expand All @@ -181,7 +184,7 @@ class App {
}
};
}
await this.client.issues.lock(issue);
await this.client.rest.issues.lock(issue);

if (actionError) {
throw actionError;
Expand Down Expand Up @@ -213,7 +216,7 @@ async function getActionConfig(client, configPath) {
try {
({
data: {content: configData}
} = await client.repos.getContent({
} = await client.rest.repos.getContent({
...github.context.repo,
path: configPath
}));
Expand Down

0 comments on commit 7c35b1c

Please sign in to comment.