diff --git a/.licenses/npm/@actions/core.dep.yml b/.licenses/npm/@actions/core.dep.yml index 4d3f93c..b468d55 100644 --- a/.licenses/npm/@actions/core.dep.yml +++ b/.licenses/npm/@actions/core.dep.yml @@ -1,6 +1,6 @@ --- name: "@actions/core" -version: 0.0.0 +version: 1.10.0 type: npm summary: Actions core lib homepage: https://github.com/actions/toolkit/tree/master/packages/core diff --git a/.licenses/npm/@actions/exec.dep.yml b/.licenses/npm/@actions/exec.dep.yml index 41b3b63..7899004 100644 --- a/.licenses/npm/@actions/exec.dep.yml +++ b/.licenses/npm/@actions/exec.dep.yml @@ -1,6 +1,6 @@ --- name: "@actions/exec" -version: 0.0.0 +version: 1.1.1 type: npm summary: Actions exec lib homepage: https://github.com/actions/toolkit/tree/master/packages/exec diff --git a/.licenses/npm/@actions/github.dep.yml b/.licenses/npm/@actions/github.dep.yml index b96031c..6e8c6fc 100644 --- a/.licenses/npm/@actions/github.dep.yml +++ b/.licenses/npm/@actions/github.dep.yml @@ -1,6 +1,6 @@ --- name: "@actions/github" -version: 0.0.0 +version: 5.1.1 type: npm summary: Actions github lib homepage: https://github.com/actions/toolkit/tree/master/packages/github diff --git a/.licenses/npm/@actions/io.dep.yml b/.licenses/npm/@actions/io.dep.yml index e7fd524..c78db09 100644 --- a/.licenses/npm/@actions/io.dep.yml +++ b/.licenses/npm/@actions/io.dep.yml @@ -1,6 +1,6 @@ --- name: "@actions/io" -version: 0.0.0 +version: 1.1.2 type: npm summary: Actions io lib homepage: https://github.com/actions/toolkit/tree/master/packages/io diff --git a/.licenses/npm/@actions/tool-cache.dep.yml b/.licenses/npm/@actions/tool-cache.dep.yml index adf4890..fb14732 100644 --- a/.licenses/npm/@actions/tool-cache.dep.yml +++ b/.licenses/npm/@actions/tool-cache.dep.yml @@ -1,6 +1,6 @@ --- name: "@actions/tool-cache" -version: 0.0.0 +version: 2.0.1 type: npm summary: Actions tool-cache lib homepage: https://github.com/actions/toolkit/tree/master/packages/exec diff --git a/lib/main.js b/lib/main.js index 32606ba..1819cf6 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,19 +1,32 @@ "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(require("@actions/core")); const github = __importStar(require("@actions/github")); @@ -26,7 +39,7 @@ function run() { throw new Error('Action must have at least one of issue-message or pr-message set'); } // Get client and context - const client = new github.GitHub(core.getInput('repo-token', { required: true })); + const client = github.getOctokit(core.getInput('repo-token', { required: true })); const context = github.context; if (context.payload.action !== 'opened') { console.log('No issue or PR was opened, skipping'); @@ -66,7 +79,7 @@ function run() { // Add a comment to the appropriate place console.log(`Adding message: ${message} to ${issueType} ${issue.number}`); if (isIssue) { - yield client.issues.createComment({ + yield client.rest.issues.createComment({ owner: issue.owner, repo: issue.repo, issue_number: issue.number, @@ -74,7 +87,7 @@ function run() { }); } else { - yield client.pulls.createReview({ + yield client.rest.pulls.createReview({ owner: issue.owner, repo: issue.repo, pull_number: issue.number, @@ -91,7 +104,7 @@ function run() { } function isFirstIssue(client, owner, repo, sender, curIssueNumber) { return __awaiter(this, void 0, void 0, function* () { - const { status, data: issues } = yield client.issues.listForRepo({ + const { status, data: issues } = yield client.rest.issues.listForRepo({ owner: owner, repo: repo, creator: sender, @@ -113,10 +126,11 @@ function isFirstIssue(client, owner, repo, sender, curIssueNumber) { } // No way to filter pulls by creator function isFirstPull(client, owner, repo, sender, curPullNumber, page = 1) { + var _a; return __awaiter(this, void 0, void 0, function* () { // Provide console output if we loop for a while. console.log('Checking...'); - const { status, data: pulls } = yield client.pulls.list({ + const { status, data: pulls } = yield client.rest.pulls.list({ owner: owner, repo: repo, per_page: 100, @@ -130,7 +144,7 @@ function isFirstPull(client, owner, repo, sender, curPullNumber, page = 1) { return true; } for (const pull of pulls) { - const login = pull.user.login; + const login = (_a = pull.user) === null || _a === void 0 ? void 0 : _a.login; if (login === sender && pull.number < curPullNumber) { return false; } diff --git a/package.json b/package.json index b1d7151..7c403a6 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,11 @@ }, "homepage": "https://github.com/actions/first-interaction#readme", "dependencies": { - "@actions/core": "file:toolkit/actions-core-0.0.0.tgz", - "@actions/exec": "file:toolkit/actions-exec-0.0.0.tgz", - "@actions/github": "file:toolkit/actions-github-0.0.0.tgz", - "@actions/io": "file:toolkit/actions-io-0.0.0.tgz", - "@actions/tool-cache": "file:toolkit/actions-tool-cache-0.0.0.tgz" + "@actions/core": "file:toolkit/actions-core-1.10.0.tgz", + "@actions/exec": "file:toolkit/actions-exec-1.1.1.tgz", + "@actions/github": "file:toolkit/actions-github-5.1.1.tgz", + "@actions/io": "file:toolkit/actions-io-1.1.2.tgz", + "@actions/tool-cache": "file:toolkit/actions-tool-cache-2.0.1.tgz" }, "devDependencies": { "@types/jest": "^24.0.13", diff --git a/src/main.ts b/src/main.ts index f386399..9bf5827 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,7 +11,7 @@ async function run() { ); } // Get client and context - const client: github.GitHub = new github.GitHub( + const client = github.getOctokit( core.getInput('repo-token', {required: true}) ); const context = github.context; @@ -71,14 +71,14 @@ async function run() { // Add a comment to the appropriate place console.log(`Adding message: ${message} to ${issueType} ${issue.number}`); if (isIssue) { - await client.issues.createComment({ + await client.rest.issues.createComment({ owner: issue.owner, repo: issue.repo, issue_number: issue.number, body: message }); } else { - await client.pulls.createReview({ + await client.rest.pulls.createReview({ owner: issue.owner, repo: issue.repo, pull_number: issue.number, @@ -87,19 +87,19 @@ async function run() { }); } } catch (error) { - core.setFailed(error.message); + core.setFailed((error as any).message); return; } } async function isFirstIssue( - client: github.GitHub, + client: ReturnType, owner: string, repo: string, sender: string, curIssueNumber: number ): Promise { - const {status, data: issues} = await client.issues.listForRepo({ + const {status, data: issues} = await client.rest.issues.listForRepo({ owner: owner, repo: repo, creator: sender, @@ -125,7 +125,7 @@ async function isFirstIssue( // No way to filter pulls by creator async function isFirstPull( - client: github.GitHub, + client: ReturnType, owner: string, repo: string, sender: string, @@ -134,7 +134,7 @@ async function isFirstPull( ): Promise { // Provide console output if we loop for a while. console.log('Checking...'); - const {status, data: pulls} = await client.pulls.list({ + const {status, data: pulls} = await client.rest.pulls.list({ owner: owner, repo: repo, per_page: 100, @@ -151,7 +151,7 @@ async function isFirstPull( } for (const pull of pulls) { - const login: string = pull.user.login; + const login = pull.user?.login; if (login === sender && pull.number < curPullNumber) { return false; } diff --git a/toolkit/actions-core-0.0.0.tgz b/toolkit/actions-core-0.0.0.tgz deleted file mode 100644 index 2baac7a..0000000 Binary files a/toolkit/actions-core-0.0.0.tgz and /dev/null differ diff --git a/toolkit/actions-core-1.10.0.tgz b/toolkit/actions-core-1.10.0.tgz new file mode 100644 index 0000000..3154fa3 Binary files /dev/null and b/toolkit/actions-core-1.10.0.tgz differ diff --git a/toolkit/actions-exec-0.0.0.tgz b/toolkit/actions-exec-0.0.0.tgz deleted file mode 100644 index 21d7144..0000000 Binary files a/toolkit/actions-exec-0.0.0.tgz and /dev/null differ diff --git a/toolkit/actions-exec-1.1.1.tgz b/toolkit/actions-exec-1.1.1.tgz new file mode 100644 index 0000000..f3ed555 Binary files /dev/null and b/toolkit/actions-exec-1.1.1.tgz differ diff --git a/toolkit/actions-github-0.0.0.tgz b/toolkit/actions-github-0.0.0.tgz deleted file mode 100644 index 6cbe36d..0000000 Binary files a/toolkit/actions-github-0.0.0.tgz and /dev/null differ diff --git a/toolkit/actions-github-5.1.1.tgz b/toolkit/actions-github-5.1.1.tgz new file mode 100644 index 0000000..9792974 Binary files /dev/null and b/toolkit/actions-github-5.1.1.tgz differ diff --git a/toolkit/actions-io-0.0.0.tgz b/toolkit/actions-io-0.0.0.tgz deleted file mode 100644 index fdd27e2..0000000 Binary files a/toolkit/actions-io-0.0.0.tgz and /dev/null differ diff --git a/toolkit/actions-io-1.1.2.tgz b/toolkit/actions-io-1.1.2.tgz new file mode 100644 index 0000000..b6095df Binary files /dev/null and b/toolkit/actions-io-1.1.2.tgz differ diff --git a/toolkit/actions-tool-cache-0.0.0.tgz b/toolkit/actions-tool-cache-0.0.0.tgz deleted file mode 100644 index d3a5220..0000000 Binary files a/toolkit/actions-tool-cache-0.0.0.tgz and /dev/null differ diff --git a/toolkit/actions-tool-cache-2.0.1.tgz b/toolkit/actions-tool-cache-2.0.1.tgz new file mode 100644 index 0000000..1b3f60d Binary files /dev/null and b/toolkit/actions-tool-cache-2.0.1.tgz differ