matryer / xbar

Put the output from any script or program into your macOS Menu Bar (the BitBar reboot)
https://xbarapp.com
MIT License
17.45k stars 641 forks source link

display_title is not showing up #890

Closed prathamesh-dev9 closed 1 year ago

prathamesh-dev9 commented 1 year ago

I'm creating a simple plugin which will fetch all GitHub workflow runs and displaying them with their name with status. But unfortunately, it is giving me error. If i'm accessing name or any other value of workflow ${workflow['name'] then plugin is working fine.

Xbar - v2.7.1-beta

Please look into this issue

image

My code is as below

#!/usr/bin/env /path_to_node_executable

const axios = require("axios");
const accessToken = "github_access_token";
const apiUrl = "https://api.github.com/repos/user_name/repo_name/actions/runs";

axios
  .get(apiUrl, {
    headers: {
      Authorization: `Bearer ${accessToken}`,
      Accept: "application/vnd.github.v3+json",
    },
  })
  .then((response) => {
    const data = response.data;
    // Filter and display the running workflows
    const runningWorkflows = data.workflow_runs.filter(
      (run) => run.status === "in_progress"
    );
    console.log(`Running Workflows (${runningWorkflows.length}):`);
    console.log("---");
    // Filter and display the completed workflows
    const completedWorkflows = data.workflow_runs.filter(
      (run) => run.status !== "in_progress"
    );

    console.log("---");
    console.log(`Completed Workflows (${completedWorkflows.length}):`);
    console.log("---");
    completedWorkflows.forEach((workflow) => {
      console.log(`${workflow["display_title"]} -> ${workflow["status"]}`);
    });
  })
  .catch((error) => {
    console.log(`Failed to fetch workflow runs. Error: ${error}`);
  });