Skip to content

Commit

Permalink
Update setStableTag.js (#3082)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm1957 authored Dec 18, 2023
1 parent f705b8b commit 4f4150a
Showing 1 changed file with 2 additions and 48 deletions.
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

0 comments on commit 4f4150a

Please sign in to comment.