Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update setStableTag.js #3082

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 2 additions & 48 deletions lib/setStableTag.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
'use strict';
const fs = require('fs');
const execSync = require('child_process').execSync;

const {
// addComment,
// addLabel,
// getGithub,
getUrl,
// getAllComments,
// deleteComment
} = require('./common');

const STABLE_JSON = 'sources-dist-stable.json';
Expand All @@ -32,48 +26,8 @@ async function getNpmDisttags(pAdapter) {
return npmMeta['dist-tags'];
};

function getPullRequestNumber() {
if (process.env.GITHUB_REF && process.env.GITHUB_REF.match(/refs\/pull\/\d+\/merge/)) {
const result = /refs\/pull\/(\d+)\/merge/g.exec(process.env.GITHUB_REF);
if (!result) {
console.log ('GITHUB_REF not found or not parseable.');
return null;
}
return result[1];
} else if (process.env.GITHUB_EVENT_PATH) {
const event = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8'));
return event.pull_request ? event.pull_request.number : (event.issue ? event.issue.number : '');
} else {
console.log ('GITHUB_REF and process.env.GITHUB_EVENT_PATH are not set!');
return null;
}
}

async function doIt() {

if (process.env.GITHUB_EVENT_PATH) {
const eventText = fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8');
console.log (eventText);

const event = JSON.parse(eventText);
}

const prID = getPullRequestNumber();
console.log(`Process PR ${prID}`);

if (prID) {
const files = await getGithub(`https://api.github.com/repos/ioBroker/ioBroker.repositories/pulls/${prID}/files`);
console.log('Files changed:');
files.forEach( f=>{console.log(` ${f}`)});
const isStable = files.includes(`${STABLE_JSON}`)
if (!isStable)
{
return 'No changes to stable repository detected';
}
} else {
console.log(`scanning ${STABLE_JSON} ...`);
}

const stable=await getStableRepo();
for (const adapter in stable) {
if (ADAPTER_LIST.includes( adapter )) {
Expand Down Expand Up @@ -107,8 +61,8 @@ async function doIt() {
//process.env.OWN_GITHUB_TOKEN = 'add-token-here';
//process.env.GITHUB_EVENT_PATH = __dirname + '/../event.json';

console.log(`process.env.GITHUB_REF = ${process.env.GITHUB_REF}`);
console.log(`process.env.GITHUB_EVENT_PATH = ${process.env.GITHUB_EVENT_PATH}`);
//console.log(`process.env.GITHUB_REF = ${process.env.GITHUB_REF}`);
//console.log(`process.env.GITHUB_EVENT_PATH = ${process.env.GITHUB_EVENT_PATH}`);
console.log(`process.env.OWN_GITHUB_TOKEN = ${(process.env.OWN_GITHUB_TOKEN || '').length}`);
console.log(`process.env.NPM_TOKEN = ${(process.env.NPM_TOKEN || '').length}`);

Expand Down