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 4042fad commit 30b1031
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class App {
try {
await this.ensureUnlock(issue, lock, () =>
(isReviewComment
? this.client.pulls.updateReviewComment
: this.client.issues.updateComment)({
? this.client.rest.pulls.updateReviewComment
: this.client.rest.issues.updateComment)({
...comment,
body: editedComment
})
Expand All @@ -136,8 +136,8 @@ class App {
try {
await this.ensureUnlock(issue, lock, () =>
(isReviewComment
? this.client.pulls.deleteReviewComment
: this.client.issues.deleteComment)(comment)
? this.client.rest.pulls.deleteReviewComment
: this.client.rest.issues.deleteComment)(comment)
);
} catch (err) {
if (err.status === 404) {
Expand All @@ -163,7 +163,7 @@ class App {

const {
data: {workflow_id: workflowId}
} = await this.client.actions.getWorkflowRun({
} = await this.client.rest.actions.getWorkflowRun({
owner,
repo,
run_id: github.context.runId
Expand All @@ -173,7 +173,7 @@ class App {
data: {
workflow_runs: [lastScheduledRun]
}
} = await this.client.actions.listWorkflowRuns({
} = await this.client.rest.actions.listWorkflowRuns({
owner,
repo,
event: 'schedule',
Expand All @@ -193,7 +193,7 @@ class App {
}

const workflowRuns = await this.client.paginate(
this.client.actions.listWorkflowRuns,
this.client.rest.actions.listWorkflowRuns,
{
owner,
repo,
Expand Down Expand Up @@ -247,11 +247,11 @@ class App {
({
data: {body: commentBody}
} = await (isReviewComment
? this.client.pulls.getReviewComment
: this.client.issues.getComment)(comment));
? this.client.rest.pulls.getReviewComment
: this.client.rest.issues.getComment)(comment));
} catch (err) {
if (err.status === 404) {
await this.client.actions.deleteArtifact({
await this.client.rest.actions.deleteArtifact({
owner,
repo,
artifact_id: artifactId
Expand All @@ -266,7 +266,7 @@ class App {
}

if (/<!--notice-->/.test(commentBody) || reactionRx.test(commentBody)) {
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'
Expand All @@ -281,11 +281,11 @@ class App {
core.debug(`Deleting comment (comment: ${commentId})`);
await this.ensureUnlock(issue, lock, () =>
(isReviewComment
? this.client.pulls.deleteReviewComment
: this.client.issues.deleteComment)(comment)
? this.client.rest.pulls.deleteReviewComment
: this.client.rest.issues.deleteComment)(comment)
);

await this.client.actions.deleteArtifact({
await this.client.rest.actions.deleteArtifact({
owner,
repo,
artifact_id: artifactId
Expand All @@ -310,7 +310,7 @@ class App {
}

if (lastScheduledRunArtifactId) {
await this.client.actions.deleteArtifact({
await this.client.rest.actions.deleteArtifact({
owner,
repo,
artifact_id: lastScheduledRunArtifactId
Expand All @@ -327,7 +327,7 @@ class App {

const {
data: {artifacts}
} = await this.client.actions.listWorkflowRunArtifacts({
} = await this.client.rest.actions.listWorkflowRunArtifacts({
owner,
repo,
run_id: runId
Expand All @@ -338,7 +338,7 @@ class App {
);

if (artifact) {
const {data: archive} = await this.client.actions.downloadArtifact({
const {data: archive} = await this.client.rest.actions.downloadArtifact({
owner,
repo,
artifact_id: artifact.id,
Expand Down Expand Up @@ -386,15 +386,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 @@ -412,7 +412,7 @@ class App {
}
};
}
await this.client.issues.lock(issue);
await this.client.rest.issues.lock(issue);

if (actionError) {
throw actionError;
Expand Down

0 comments on commit 30b1031

Please sign in to comment.