From 0bfab204ca20fbd3638ea09b768e5b37ed736de2 Mon Sep 17 00:00:00 2001 From: Tim Gymnich Date: Tue, 15 Sep 2020 00:00:29 +0200 Subject: [PATCH] fixed retry plugin --- lib/main.js | 5 +++-- package-lock.json | 35 +++++++++++++++++++++++++++-------- package.json | 6 +++--- src/main.ts | 5 +++-- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index e07ffda8..84223bcc 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,8 @@ const { Octokit } = require("@octokit/rest"); const { retry } = require("@octokit/plugin-retry"); const githubToken = core.getInput('github_token', { required: true }); const context = Github.context; -const octokit = new Octokit({ auth: githubToken }); +const MyOctokit = Octokit.plugin(retry); +const octokit = new MyOctokit({ auth: githubToken }); function run() { return __awaiter(this, void 0, void 0, function* () { const owner = core.getInput('owner', { required: false }) || context.repo.owner; @@ -46,7 +47,7 @@ function run() { const ignoreFail = core.getInput('ignore_fail', { required: false }); try { let pr = yield octokit.pulls.create({ owner: context.repo.owner, repo: context.repo.repo, title: prTitle, head: owner + ':' + head, base: base, body: prMessage, merge_method: mergeMethod, maintainer_can_modify: false }); - yield octokit.pulls.merge({ owner: context.repo.owner, repo: context.repo.repo, pull_number: Number(pr.data.number) }); + yield octokit.pulls.merge({ owner: context.repo.owner, repo: context.repo.repo, pull_number: pr.data.number }); } catch (error) { if (!!error.errors && error.errors[0].message.startsWith('No commits between')) { diff --git a/package-lock.json b/package-lock.json index 903f3ffe..40674b30 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "fork-sync", - "version": "1.2.0", + "version": "1.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -126,14 +126,33 @@ } }, "@octokit/rest": { - "version": "18.0.5", - "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.0.5.tgz", - "integrity": "sha512-SPKI24tQXrr1XsnaIjv2x0rl4M5eF1+hj8+vMe3d/exZ7NnL5sTe1BuFyCyJyrc+j1HkXankvgGN9zT0rwBwtg==", + "version": "18.0.6", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.0.6.tgz", + "integrity": "sha512-ES4lZBKPJMX/yUoQjAZiyFjei9pJ4lTTfb9k7OtYoUzKPDLl/M8jiHqt6qeSauyU4eZGLw0sgP1WiQl9FYeM5w==", "requires": { "@octokit/core": "^3.0.0", "@octokit/plugin-paginate-rest": "^2.2.0", "@octokit/plugin-request-log": "^1.0.0", - "@octokit/plugin-rest-endpoint-methods": "4.1.4" + "@octokit/plugin-rest-endpoint-methods": "4.2.0" + }, + "dependencies": { + "@octokit/plugin-rest-endpoint-methods": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.2.0.tgz", + "integrity": "sha512-1/qn1q1C1hGz6W/iEDm9DoyNoG/xdFDt78E3eZ5hHeUfJTLJgyAMdj9chL/cNBHjcjd+FH5aO1x0VCqR2RE0mw==", + "requires": { + "@octokit/types": "^5.5.0", + "deprecation": "^2.3.1" + } + }, + "@octokit/types": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-5.5.0.tgz", + "integrity": "sha512-UZ1pErDue6bZNjYOotCNveTXArOMZQFG6hKJfOnGnulVCMcVVi7YIIuuR4WfBhjo7zgpmzn/BkPDnUXtNx+PcQ==", + "requires": { + "@types/node": ">= 8" + } + } } }, "@octokit/types": { @@ -145,9 +164,9 @@ } }, "@types/node": { - "version": "14.6.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.4.tgz", - "integrity": "sha512-Wk7nG1JSaMfMpoMJDKUsWYugliB2Vy55pdjLpmLixeyMi7HizW2I/9QoxsPCkXl3dO+ZOVqPumKaDUv5zJu2uQ==" + "version": "14.10.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.10.1.tgz", + "integrity": "sha512-aYNbO+FZ/3KGeQCEkNhHFRIzBOUgc7QvcVNKXbfnhDkSfwUv91JsQQa10rDgKSTSLkXZ1UIyPe4FJJNVgw1xWQ==" }, "@types/promise-retry": { "version": "1.1.3", diff --git a/package.json b/package.json index 05689e7d..baba4c81 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fork-sync", - "version": "1.2.0", + "version": "1.2.1", "private": true, "description": "Keep your fork up to date", "main": "lib/main.js", @@ -26,11 +26,11 @@ "@actions/core": "^1.2.5", "@actions/github": "^4.0.0", "@octokit/plugin-retry": "^3.0.0", - "@octokit/rest": "^18.0.0", + "@octokit/rest": "^18.0.6", "@types/promise-retry": "^1.1.3" }, "devDependencies": { - "@types/node": "^14.6.0", + "@types/node": "^14.10.1", "typescript": "^4.0.0" } } diff --git a/src/main.ts b/src/main.ts index 37ea2647..0c96abb3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,7 +4,8 @@ const { Octokit } = require("@octokit/rest"); const { retry } = require("@octokit/plugin-retry"); const githubToken = core.getInput('github_token', { required: true }); const context = Github.context; -const octokit = new Octokit({auth: githubToken}); +const MyOctokit = Octokit.plugin(retry) +const octokit = new MyOctokit({auth: githubToken}); async function run() { const owner = core.getInput('owner', { required: false }) || context.repo.owner; @@ -17,7 +18,7 @@ async function run() { try { let pr = await octokit.pulls.create({ owner: context.repo.owner, repo: context.repo.repo, title: prTitle, head: owner + ':' + head, base: base, body: prMessage, merge_method: mergeMethod, maintainer_can_modify: false }); - await octokit.pulls.merge({ owner: context.repo.owner, repo: context.repo.repo, pull_number: Number(pr.data.number) }); + await octokit.pulls.merge({ owner: context.repo.owner, repo: context.repo.repo, pull_number: pr.data.number }); } catch (error) { if (!!error.errors && error.errors[0].message.startsWith('No commits between')) { console.log('No commits between ' + context.repo.owner + ':' + base + ' and ' + owner + ':' + head);