How To Build Scheduled Task on Github Libraries Releases via Slack Apps and NodeJs

This page summarizes the projects mentioned and recommended in the original post on dev.to

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • Zilon

    Scheduled Task to Check Github Libraries Releases and Send Messages with Libraries Update

  • Github Repository

  • Puts Debuggerer

    Ruby library for improved puts debugging, automatically displaying bonus useful information such as source line number and source code.

  • export class GithubDependenciesManager { private static GITHUB_LIBRARIES_FILE = "github-libraries.json"; private static CONSOLE_LOGGING_KEY = "[Github Dependencies Manager]"; private static GITHUB_CACHE_FILE = "github-libraries-cache.json"; private static CONFIG_FILE = "config.json"; /** * Main Method to Start inside This Manager * 1. Create and Validate the Local Json Files * 2. Start Validating The Old Files if Exists, if Not Will Create Default Files * 3. Will loop on all of them to see if the current version on github is similar to cached version * if not will send message on slack channel via config.json token, channelId */ public async validateGithubLibrariesFile() { const fs = require("fs"); this.createGithubLibrariesFile(); let configFile = new ApplicationConfigFile("", "", "", true, "", ""); if (fs.existsSync(GithubDependenciesManager.CONFIG_FILE)) { const dataFile = fs.readFileSync(GithubDependenciesManager.CONFIG_FILE); configFile = JSON.parse(dataFile.toString()); } let librariesInformation = new Array(); let librariesFile = new GithubContainerFileContent(new Array()); if (fs.existsSync(GithubDependenciesManager.GITHUB_LIBRARIES_FILE)) { const data = fs.readFileSync(GithubDependenciesManager.GITHUB_LIBRARIES_FILE, "utf8"); librariesFile = JSON.parse(data); for (let i = 0; i < librariesFile.libraries.length; i++) { const library = librariesFile.libraries[i]; await timer(5000); await NetworkInstance.getGithubRepositoriesInstance().get>(this.getGithubRequestUrl(configFile, NetworkInstance.GITHUB_REPOS_KEY + library.url + NetworkInstance.GITHUB_RELEASES_KEY), { method: "get" }).then((response) => { if (response.status == NetworkInstance.SUCCESS_RESPONSE_CODE) { librariesInformation.push({ name: library.name, url: library.url, releases: response.data }); } else { console.error(GithubDependenciesManager.CONSOLE_LOGGING_KEY + " Exception : " + response.data + " Response : " + response.statusText); } }).catch((exception) => { console.error(GithubDependenciesManager.CONSOLE_LOGGING_KEY + " Exception : " + exception); }); } this.validateGithubRepositoriesReleasesVersions(librariesInformation); } } private getGithubRequestUrl(config: ApplicationConfigFile, url: string): string { return url + "?client_id=" + config.githubClientId + "&client_secret=" + config.githubClientSecrete; } /** * After Get all Releases From Github Api to Get All Releases Information * We Will Validate the First Release With The Cached Versions if Not Equals * Will Send Slack Message with The New Version Triggered ... * @param libraries * @private */ private validateGithubRepositoriesReleasesVersions(libraries: Array) { const fs = require("fs"); let librariesFile = new GithubLibrariesCacheContainer(new Array()); const requireUpdateLibraries = new Array(); fs.readFile(GithubDependenciesManager.GITHUB_CACHE_FILE, "utf8", function readFileCallback(err, data) { if (err) { console.log(err); } else { librariesFile = JSON.parse(data); for (let i = 0; i < librariesFile.libraries.length; i++) { const cachedLibrary = librariesFile.libraries[i]; for (let j = 0; j < libraries.length; j++) { const triggeredLibrary = libraries[j]; if (cachedLibrary.name.includes(triggeredLibrary.name) && triggeredLibrary.releases != null) { if (!cachedLibrary.release.includes(triggeredLibrary.releases[triggeredLibrary.releases.length - 1].ref.replace("refs/tags/", ""))) { console.log(GithubDependenciesManager.CONSOLE_LOGGING_KEY + " Library Need Update : " + triggeredLibrary.name + " Version : " + cachedLibrary.release + " Updated Version : " + triggeredLibrary.releases[triggeredLibrary.releases.length - 1].ref.replace("refs/tags/", "")); requireUpdateLibraries.push({ isGithubSource: true, releaseUrl: "https://github.com/" + triggeredLibrary.url + "/releases", version: triggeredLibrary.releases[triggeredLibrary.releases.length - 1].ref.replace("refs/tags/", ""), url: "https://github.com/" + triggeredLibrary.url, artifact: "", groupId: "", name: triggeredLibrary.url.split("/")[1] }); } } } } new MessagingManager().sendMessageUpdateDependencies(requireUpdateLibraries); GithubDependenciesManager.saveNewGithubRepositoriesCacheFile(libraries); } }); } /** * After Updating the Required Dependencies and Send All of them inside Messages in Slack * Now we Want to Refresh the Json File with New Cached Data * To Save The Notified Releases * @param libraries * @private */ private static saveNewGithubRepositoriesCacheFile(libraries: Array) { const fs = require("fs"); if (fs.existsSync(GithubDependenciesManager.GITHUB_CACHE_FILE)) { const librariesFile = new GithubLibrariesCacheContainer(new Array()); for (let i = 0; i < libraries.length; i++) { try { const library = libraries[i]; librariesFile.libraries.push({ name: library.name, release: library.releases[library.releases.length - 1].ref.replace("refs/tags/", "") }); } catch (error) { console.error(error); } } const json = JSON.stringify(librariesFile, null, "\t"); fs.writeFile(GithubDependenciesManager.GITHUB_CACHE_FILE, json, "utf8", (exception) => { if (exception != null) { console.error(GithubDependenciesManager.CONSOLE_LOGGING_KEY + " Exception : " + exception); } }); } } }

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Extending GitOps: Effortless continuous integration and deployment on Kubernetes

    4 projects | dev.to | 26 Dec 2023
  • On seeking ideas: building the codelib.club

    2 projects | dev.to | 17 Dec 2021
  • A Beginner's Guide to Front-End Development

    1 project | dev.to | 4 May 2024
  • 5 Free Tools to Boost Developer Productivity

    1 project | dev.to | 3 May 2024
  • End-to-end MLOps CI/CD pipeline with Harness and AWS

    2 projects | dev.to | 1 May 2024