From c61538028a49917ec2ae02d53ea66dd2725ff072 Mon Sep 17 00:00:00 2001 From: MarkAckert Date: Wed, 17 Apr 2024 16:27:04 -0400 Subject: [PATCH] handle protected/unprotected branches, fix orion Signed-off-by: MarkAckert --- .../manifest_verification/check_sources.js | 26 +++++++++---- .../manifest_verification/package-lock.json | 38 ++++++------------- .../manifest_verification/package.json | 2 +- manifest.json.template | 2 +- 4 files changed, 33 insertions(+), 35 deletions(-) diff --git a/.github/scripts/manifest_verification/check_sources.js b/.github/scripts/manifest_verification/check_sources.js index f902c437a5..7c1598bbdd 100644 --- a/.github/scripts/manifest_verification/check_sources.js +++ b/.github/scripts/manifest_verification/check_sources.js @@ -2,7 +2,6 @@ const core = require('@actions/core'); const fs = require('fs-extra'); -const { Octokit } = require('@octokit/rest') const results = { success: 'found_matching_tag', @@ -29,9 +28,8 @@ async function main() { const baseRef = process.env['BASE_REF'].trim(); - const github = new Octokit({ - auth: process.env['GITHUB_TOKEN'] - }); + const github = require('@actions/github') + const octokit = github.getOctokit(process.env['GITHUB_TOKEN']); // expect script to be run from repo root const sourceDeps = fs.readJSONSync('./manifest.json.template').sourceDependencies; @@ -59,7 +57,7 @@ async function main() { const repo = entry.repository; const tag = entry.tag; - const tags = await github.rest.repos.listTags({ + const tags = await octokit.rest.repos.listTags({ owner: 'zowe', repo: repo, }).then((resp) => { @@ -75,9 +73,21 @@ async function main() { } // if we didn't find tag, look at branches - const branches = await github.rest.repos.listBranches({ + // 2 REST Requests, unset protected was operating as protected=false + const protBranches = await octokit.rest.repos.listBranches({ owner: 'zowe', - repo: repo + repo: repo, + protected: true + }).then((resp) => { + if (resp.status < 400) { + return resp.data; + } + return []; + }) + const unProtBranches = await octokit.rest.repos.listBranches({ + owner: 'zowe', + repo: repo, + protected: false }).then((resp) => { if (resp.status < 400) { return resp.data; @@ -85,6 +95,8 @@ async function main() { return []; }) + const branches = [...protBranches, ...unProtBranches]; + const knownBranch = branches.find((item) => item.name === tag); if (knownBranch != null && knownBranch.name.trim().length > 0) { analyzedRepos.push({repository: repo, tag: tag, result: results.warn}); diff --git a/.github/scripts/manifest_verification/package-lock.json b/.github/scripts/manifest_verification/package-lock.json index 7b11cf1953..784fe7954d 100644 --- a/.github/scripts/manifest_verification/package-lock.json +++ b/.github/scripts/manifest_verification/package-lock.json @@ -10,7 +10,7 @@ "license": "EPL-2.0", "dependencies": { "@actions/core": "1.10.1", - "@octokit/rest": "20.1.0", + "@actions/github": "^6.0.0", "fs-extra": "11.2.0" } }, @@ -23,6 +23,17 @@ "uuid": "^8.3.2" } }, + "node_modules/@actions/github": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@actions/github/-/github-6.0.0.tgz", + "integrity": "sha512-alScpSVnYmjNEXboZjarjukQEzgCRmjMv6Xj47fsdnqGS73bjJNDpiiXmp8jr0UZLdUB6d9jW63IcmddUP+l0g==", + "dependencies": { + "@actions/http-client": "^2.2.0", + "@octokit/core": "^5.0.1", + "@octokit/plugin-paginate-rest": "^9.0.0", + "@octokit/plugin-rest-endpoint-methods": "^10.0.0" + } + }, "node_modules/@actions/http-client": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.1.tgz", @@ -122,17 +133,6 @@ "@octokit/openapi-types": "^20.0.0" } }, - "node_modules/@octokit/plugin-request-log": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-4.0.1.tgz", - "integrity": "sha512-GihNqNpGHorUrO7Qa9JbAl0dbLnqJVrV8OXe2Zm5/Y4wFkZQDfTreBzVmiRfJVfE4mClXdihHnbpyyO9FSX4HA==", - "engines": { - "node": ">= 18" - }, - "peerDependencies": { - "@octokit/core": "5" - } - }, "node_modules/@octokit/plugin-rest-endpoint-methods": { "version": "10.4.1", "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.4.1.tgz", @@ -187,20 +187,6 @@ "node": ">= 18" } }, - "node_modules/@octokit/rest": { - "version": "20.1.0", - "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-20.1.0.tgz", - "integrity": "sha512-STVO3itHQLrp80lvcYB2UIKoeil5Ctsgd2s1AM+du3HqZIR35ZH7WE9HLwUOLXH0myA0y3AGNPo8gZtcgIbw0g==", - "dependencies": { - "@octokit/core": "^5.0.2", - "@octokit/plugin-paginate-rest": "^9.1.5", - "@octokit/plugin-request-log": "^4.0.0", - "@octokit/plugin-rest-endpoint-methods": "^10.2.0" - }, - "engines": { - "node": ">= 18" - } - }, "node_modules/@octokit/types": { "version": "13.4.1", "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.4.1.tgz", diff --git a/.github/scripts/manifest_verification/package.json b/.github/scripts/manifest_verification/package.json index 8e4f327439..eeb1997434 100644 --- a/.github/scripts/manifest_verification/package.json +++ b/.github/scripts/manifest_verification/package.json @@ -10,7 +10,7 @@ "license": "EPL-2.0", "dependencies": { "@actions/core": "1.10.1", - "@octokit/rest": "20.1.0", + "@actions/github": "^6.0.0", "fs-extra": "11.2.0" } } diff --git a/manifest.json.template b/manifest.json.template index f3388e1aeb..abd6ba1afc 100644 --- a/manifest.json.template +++ b/manifest.json.template @@ -274,7 +274,7 @@ "componentGroup": "Zowe Desktop Eclipse Orion-based React Editor", "entries": [{ "repository": "orion-editor-component", - "tag": "master", + "tag": "v2.x/master", "destinations": ["Zowe PAX"] }] }, {