Add retry mechanism to octokit client

This commit is contained in:
Imran Ismail
2021-01-20 03:02:45 +08:00
parent 91ce0fb611
commit 60866b9f80
3 changed files with 34 additions and 1 deletions

30
package-lock.json generated
View File

@@ -1434,6 +1434,11 @@
"universal-user-agent": "^6.0.0"
}
},
"@octokit/openapi-types": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-2.3.1.tgz",
"integrity": "sha512-KTzpRDT07euvbBYbPs121YDqq5DT94nBDFIyogsDhOnWL8yDCHev6myeiPTgS+VLmyUbdNCYu6L/gVj+Bd1q8Q=="
},
"@octokit/plugin-paginate-rest": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.4.0.tgz",
@@ -1456,6 +1461,26 @@
"deprecation": "^2.3.1"
}
},
"@octokit/plugin-retry": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-3.0.6.tgz",
"integrity": "sha512-2ht+F85yN5pVw6rhFfJhrpujI8ch2lQUEEsK/Pkx3elFgh9lW4sbZXisH+uDD15+kZU5NX4zQ4ycUDofGLmhXg==",
"requires": {
"@octokit/types": "^6.0.3",
"bottleneck": "^2.15.3"
},
"dependencies": {
"@octokit/types": {
"version": "6.3.2",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.3.2.tgz",
"integrity": "sha512-H6cbnDumWOQJneyNKCBWgnktRqTWcEm6gq2cIS3frtVgpCqB8zguromnjIWJW375btjnxwmbYBTEAEouruZ2Yw==",
"requires": {
"@octokit/openapi-types": "^2.3.1",
"@types/node": ">= 8"
}
}
}
},
"@octokit/request": {
"version": "5.4.9",
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.9.tgz",
@@ -2401,6 +2426,11 @@
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.1.0.tgz",
"integrity": "sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A=="
},
"bottleneck": {
"version": "2.19.5",
"resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz",
"integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw=="
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",

View File

@@ -28,6 +28,7 @@
"@actions/core": "^1.2.6",
"@actions/io": "^1.0.2",
"@actions/tool-cache": "^1.3.3",
"@octokit/plugin-retry": "^3.0.6",
"@octokit/rest": "^18.0.6",
"semver": "^7.3.2"
},

View File

@@ -1,5 +1,6 @@
// Load tempDirectory before it gets wiped by tool-cache
import {Octokit} from '@octokit/rest'
import {retry} from '@octokit/plugin-retry'
import * as core from '@actions/core'
import * as cache from '@actions/tool-cache'
import * as path from 'path'
@@ -7,7 +8,8 @@ import * as semver from 'semver'
import * as fs from 'fs'
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || ''
const octokit = new Octokit()
const RetriableOctokit = Octokit.plugin(retry)
const octokit = new RetriableOctokit()
const versionRegex = /\d+\.?\d*\.?\d*/
const toolName = 'kustomize'
const platform = process.platform