Skip to content

Commit 51a6bff

Browse files
authored
Merge pull request #103 from thyeggman/thyeggman/fix-octokit-error
Updating bundled toolkit packages and fix error
2 parents dafa9ae + 01781a8 commit 51a6bff

18 files changed

+47
-33
lines changed

.licenses/npm/@actions/core.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@actions/exec.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@actions/github.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@actions/io.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@actions/tool-cache.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/main.js

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
"use strict";
2+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3+
if (k2 === undefined) k2 = k;
4+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5+
}) : (function(o, m, k, k2) {
6+
if (k2 === undefined) k2 = k;
7+
o[k2] = m[k];
8+
}));
9+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10+
Object.defineProperty(o, "default", { enumerable: true, value: v });
11+
}) : function(o, v) {
12+
o["default"] = v;
13+
});
14+
var __importStar = (this && this.__importStar) || function (mod) {
15+
if (mod && mod.__esModule) return mod;
16+
var result = {};
17+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18+
__setModuleDefault(result, mod);
19+
return result;
20+
};
221
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
323
return new (P || (P = Promise))(function (resolve, reject) {
424
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
525
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
26+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
727
step((generator = generator.apply(thisArg, _arguments || [])).next());
828
});
929
};
10-
var __importStar = (this && this.__importStar) || function (mod) {
11-
if (mod && mod.__esModule) return mod;
12-
var result = {};
13-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
14-
result["default"] = mod;
15-
return result;
16-
};
1730
Object.defineProperty(exports, "__esModule", { value: true });
1831
const core = __importStar(require("@actions/core"));
1932
const github = __importStar(require("@actions/github"));
@@ -26,7 +39,7 @@ function run() {
2639
throw new Error('Action must have at least one of issue-message or pr-message set');
2740
}
2841
// Get client and context
29-
const client = new github.GitHub(core.getInput('repo-token', { required: true }));
42+
const client = github.getOctokit(core.getInput('repo-token', { required: true }));
3043
const context = github.context;
3144
if (context.payload.action !== 'opened') {
3245
console.log('No issue or PR was opened, skipping');
@@ -66,15 +79,15 @@ function run() {
6679
// Add a comment to the appropriate place
6780
console.log(`Adding message: ${message} to ${issueType} ${issue.number}`);
6881
if (isIssue) {
69-
yield client.issues.createComment({
82+
yield client.rest.issues.createComment({
7083
owner: issue.owner,
7184
repo: issue.repo,
7285
issue_number: issue.number,
7386
body: message
7487
});
7588
}
7689
else {
77-
yield client.pulls.createReview({
90+
yield client.rest.pulls.createReview({
7891
owner: issue.owner,
7992
repo: issue.repo,
8093
pull_number: issue.number,
@@ -91,7 +104,7 @@ function run() {
91104
}
92105
function isFirstIssue(client, owner, repo, sender, curIssueNumber) {
93106
return __awaiter(this, void 0, void 0, function* () {
94-
const { status, data: issues } = yield client.issues.listForRepo({
107+
const { status, data: issues } = yield client.rest.issues.listForRepo({
95108
owner: owner,
96109
repo: repo,
97110
creator: sender,
@@ -113,10 +126,11 @@ function isFirstIssue(client, owner, repo, sender, curIssueNumber) {
113126
}
114127
// No way to filter pulls by creator
115128
function isFirstPull(client, owner, repo, sender, curPullNumber, page = 1) {
129+
var _a;
116130
return __awaiter(this, void 0, void 0, function* () {
117131
// Provide console output if we loop for a while.
118132
console.log('Checking...');
119-
const { status, data: pulls } = yield client.pulls.list({
133+
const { status, data: pulls } = yield client.rest.pulls.list({
120134
owner: owner,
121135
repo: repo,
122136
per_page: 100,
@@ -130,7 +144,7 @@ function isFirstPull(client, owner, repo, sender, curPullNumber, page = 1) {
130144
return true;
131145
}
132146
for (const pull of pulls) {
133-
const login = pull.user.login;
147+
const login = (_a = pull.user) === null || _a === void 0 ? void 0 : _a.login;
134148
if (login === sender && pull.number < curPullNumber) {
135149
return false;
136150
}

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
},
2727
"homepage": "https://github.com/actions/first-interaction#readme",
2828
"dependencies": {
29-
"@actions/core": "file:toolkit/actions-core-0.0.0.tgz",
30-
"@actions/exec": "file:toolkit/actions-exec-0.0.0.tgz",
31-
"@actions/github": "file:toolkit/actions-github-0.0.0.tgz",
32-
"@actions/io": "file:toolkit/actions-io-0.0.0.tgz",
33-
"@actions/tool-cache": "file:toolkit/actions-tool-cache-0.0.0.tgz"
29+
"@actions/core": "file:toolkit/actions-core-1.10.0.tgz",
30+
"@actions/exec": "file:toolkit/actions-exec-1.1.1.tgz",
31+
"@actions/github": "file:toolkit/actions-github-5.1.1.tgz",
32+
"@actions/io": "file:toolkit/actions-io-1.1.2.tgz",
33+
"@actions/tool-cache": "file:toolkit/actions-tool-cache-2.0.1.tgz"
3434
},
3535
"devDependencies": {
3636
"@types/jest": "^24.0.13",

src/main.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ async function run() {
1111
);
1212
}
1313
// Get client and context
14-
const client: github.GitHub = new github.GitHub(
14+
const client = github.getOctokit(
1515
core.getInput('repo-token', {required: true})
1616
);
1717
const context = github.context;
@@ -71,14 +71,14 @@ async function run() {
7171
// Add a comment to the appropriate place
7272
console.log(`Adding message: ${message} to ${issueType} ${issue.number}`);
7373
if (isIssue) {
74-
await client.issues.createComment({
74+
await client.rest.issues.createComment({
7575
owner: issue.owner,
7676
repo: issue.repo,
7777
issue_number: issue.number,
7878
body: message
7979
});
8080
} else {
81-
await client.pulls.createReview({
81+
await client.rest.pulls.createReview({
8282
owner: issue.owner,
8383
repo: issue.repo,
8484
pull_number: issue.number,
@@ -87,19 +87,19 @@ async function run() {
8787
});
8888
}
8989
} catch (error) {
90-
core.setFailed(error.message);
90+
core.setFailed((error as any).message);
9191
return;
9292
}
9393
}
9494

9595
async function isFirstIssue(
96-
client: github.GitHub,
96+
client: ReturnType<typeof github.getOctokit>,
9797
owner: string,
9898
repo: string,
9999
sender: string,
100100
curIssueNumber: number
101101
): Promise<boolean> {
102-
const {status, data: issues} = await client.issues.listForRepo({
102+
const {status, data: issues} = await client.rest.issues.listForRepo({
103103
owner: owner,
104104
repo: repo,
105105
creator: sender,
@@ -125,7 +125,7 @@ async function isFirstIssue(
125125

126126
// No way to filter pulls by creator
127127
async function isFirstPull(
128-
client: github.GitHub,
128+
client: ReturnType<typeof github.getOctokit>,
129129
owner: string,
130130
repo: string,
131131
sender: string,
@@ -134,7 +134,7 @@ async function isFirstPull(
134134
): Promise<boolean> {
135135
// Provide console output if we loop for a while.
136136
console.log('Checking...');
137-
const {status, data: pulls} = await client.pulls.list({
137+
const {status, data: pulls} = await client.rest.pulls.list({
138138
owner: owner,
139139
repo: repo,
140140
per_page: 100,
@@ -151,7 +151,7 @@ async function isFirstPull(
151151
}
152152

153153
for (const pull of pulls) {
154-
const login: string = pull.user.login;
154+
const login = pull.user?.login;
155155
if (login === sender && pull.number < curPullNumber) {
156156
return false;
157157
}

toolkit/actions-core-0.0.0.tgz

-3.8 KB
Binary file not shown.

toolkit/actions-core-1.10.0.tgz

19.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)