Fix rate limits in release tests (#3106)
* Fix rates limits in release tests * add authorization token to releases/latest request * fix token * add token
This commit is contained in:
parent
e69bf63498
commit
9151fb77aa
2 changed files with 18 additions and 10 deletions
16
.github/workflows/getEnvironmentVariables.js
vendored
16
.github/workflows/getEnvironmentVariables.js
vendored
|
@ -10,8 +10,12 @@ program
|
|||
.description("Approve and merge PR if patch release")
|
||||
.option("--version <version>", "version of a project")
|
||||
.option("--token <token>", "token fo login to cloud")
|
||||
.option("--repo_token <repo_token>", "github token")
|
||||
.action(async options => {
|
||||
const isOldVersion = await checkIfOldVersion(options.version);
|
||||
const isOldVersion = await checkIfOldVersion(
|
||||
options.version,
|
||||
options.repo_token,
|
||||
);
|
||||
core.setOutput("IS_OLD_VERSION", isOldVersion);
|
||||
|
||||
if (!isPatchRelease(options.version)) {
|
||||
|
@ -176,16 +180,18 @@ async function getDomainForUpdatedEnvironment(environmentId, token) {
|
|||
return responseInJson.domain;
|
||||
}
|
||||
|
||||
async function checkIfOldVersion(version) {
|
||||
const newestVersion = await getTheNewestVersion();
|
||||
async function checkIfOldVersion(version, token) {
|
||||
const newestVersion = await getTheNewestVersion(token);
|
||||
const howManyVersionsBehind =
|
||||
getFormattedVersion(newestVersion) - getFormattedVersion(version);
|
||||
//All versions besides last three are old versions
|
||||
return howManyVersionsBehind > 2 ? "true" : "false";
|
||||
}
|
||||
|
||||
async function getTheNewestVersion() {
|
||||
const octokit = new Octokit();
|
||||
async function getTheNewestVersion(token) {
|
||||
const octokit = new Octokit({
|
||||
auth: token,
|
||||
});
|
||||
|
||||
const response = await octokit.request(
|
||||
"GET /repos/{owner}/{repo}/releases/latest",
|
||||
|
|
4
.github/workflows/tests-nightly.yml
vendored
4
.github/workflows/tests-nightly.yml
vendored
|
@ -158,6 +158,7 @@ jobs:
|
|||
url: ${{ steps.get-environment-variables.outputs.url }}
|
||||
is_old_version: ${{ steps.get-environment-variables.outputs.IS_OLD_VERSION }}
|
||||
env:
|
||||
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
TOKEN: ${{ secrets.CLOUD_ACCESS_TOKEN }}
|
||||
VERSION: ${{github.event.client_payload.version}}
|
||||
steps:
|
||||
|
@ -179,7 +180,8 @@ jobs:
|
|||
run: |
|
||||
node .github/workflows/getEnvironmentVariables.js \
|
||||
--version $VERSION \
|
||||
--token "$TOKEN"
|
||||
--token "$TOKEN" \
|
||||
--repo_token "$REPO_TOKEN"
|
||||
|
||||
run-tests-on-release:
|
||||
if: ${{ github.event_name == 'repository_dispatch' && (github.event.client_payload.environment == 'SANDBOX' || github.event.client_payload.environment == 'STAGING')}}
|
||||
|
|
Loading…
Reference in a new issue