Skip to content

Commit

Permalink
handle protected/unprotected branches, fix orion
Browse files Browse the repository at this point in the history
Signed-off-by: MarkAckert <[email protected]>
  • Loading branch information
MarkAckert committed Apr 17, 2024
1 parent 81213d5 commit c615380
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 35 deletions.
26 changes: 19 additions & 7 deletions .github/scripts/manifest_verification/check_sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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;
Expand Down Expand Up @@ -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) => {
Expand All @@ -75,16 +73,30 @@ 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;
}
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});
Expand Down
38 changes: 12 additions & 26 deletions .github/scripts/manifest_verification/package-lock.json

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

2 changes: 1 addition & 1 deletion .github/scripts/manifest_verification/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion manifest.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}]
}, {
Expand Down

0 comments on commit c615380

Please sign in to comment.