Skip to content

Commit

Permalink
updating GitHub pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
agracio committed Sep 18, 2024
1 parent b671f85 commit 66fdae7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
16 changes: 3 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,9 @@ jobs:
result-encoding: string
script: |
try {
const url = 'https://nodejs.org/dist/index.json';
const result = await github.request(url);
console.log(result.data)
let json = JSON.parse(result.data);
for (const el of json.sort()) {
let version = el.version.substring(1, el.version.length) ;
if(version.startsWith(${{ inputs.build-version }})){
console.log(version);
core.setOutput("version", version);
core.setFailed(version);
//return version;
}
}
const script = require('./tools/getNodeVersion.js')
await script({${{ inputs.build-version }}, core})
core.setFailed('done')
} catch(err) {
core.error("Error while reading or parsing mochawesome.json")
core.setFailed(err)
Expand Down
36 changes: 36 additions & 0 deletions tools/getNodeVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var {http} = require('follow-redirects');

module.exports = async (majorVersion, core) => {
let url = 'http://nodejs.org/dist/index.json';

http.get(url,(res) => {
let body = "";

if (res.statusCode !== 200) {
throw new Error(`Unable to get Node.js versions from ${url}`);
}

res.on("data", (chunk) => {
body += chunk;
});

res.on("end", () => {
try {
let json = JSON.parse(body);

for (const el of json.sort()) {
let version = el.version.substring(1, el.version.length) ;
if(version.startsWith(majorVersion)){
console.log(version)
core.setOutput("version", version);
}
}
} catch (error) {
throw error;
};
});

}).on("error", (error) => {
throw new Error(error);
});
}

0 comments on commit 66fdae7

Please sign in to comment.