Skip to content

Commit

Permalink
fixed retry plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
tgymnich committed Sep 14, 2020
1 parent 8d01374 commit 0bfab20
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
5 changes: 3 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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')) {
Expand Down
35 changes: 27 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
}
}
5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 0bfab20

Please sign in to comment.