Glanceway Glanceway
所有資料來源

GitHub Notifications

開發者

Get GitHub notifications in your menu bar. Supports filtering by repository.

@codytseng #github #notifications #developer

安裝與設定方式

  1. 先在 Mac 上安裝並開啟 Glanceway,再使用上方的安裝連結。
  2. 點選「安裝到 Glanceway」。若瀏覽器無法開啟應用程式,下載 .gwsrc 檔案並在資訊源管理中匯入。
  3. 填寫以下必填欄位並儲存,設定更新間隔,等待首次成功取得內容。

設定檢查

  • GITHUB_TOKEN — 必填. Personal access token from GitHub Settings 填寫自己的存取憑證,請勿在截圖或公開檔案中分享。
  • REPOSITORY — 選填. Optional: Filter by repository (format: owner/repo)

使用具有通知存取權限的傳統個人存取權杖。GitHub 通知端點不支援細緻權杖。REPOSITORY 接受單一 owner/repo 值;空清單可能代表沒有未讀通知。

設定範例

GITHUB_TOKEN: <your GitHub classic token>
REPOSITORY: glanceway/glanceway-sources

沒有顯示內容時如何排查

  • 對照目前版本設定表檢查欄位、清單項目與憑證。下方範例不包含可用的真實憑證。
  • 檢查網路及上游服務狀態。認證失敗或速率限制可能使更新失敗,請依上游限制調整間隔。
  • 空清單也可能代表沒有符合條件的條目。內容與更新時間取決於資料提供方及資訊源實作。

設定項目

名稱 鍵 類型 必填 預設值 描述
GitHub Token GITHUB_TOKEN secret 是 — Personal access token from GitHub Settings
Repository REPOSITORY string 否 — Optional: Filter by repository (format: owner/repo)

原始碼

id: codytseng/github-notifications
version: 1.1.0
name: GitHub Notifications
description: |
  Get GitHub notifications in your menu bar.
  Supports filtering by repository.
author: codytseng
author_url: https://github.com/codytseng
category: Developer
tags:
  - github
  - notifications
  - developer

config:
  - key: GITHUB_TOKEN
    name: GitHub Token
    type: secret
    required: true
    description: "Personal access token from GitHub Settings"
  - key: REPOSITORY
    name: Repository
    type: string
    required: false
    description: "Optional: Filter by repository (format: owner/repo)"
module.exports = async (api) => {
  const token = api.config.get("GITHUB_TOKEN");
  const repository = api.config.get("REPOSITORY");

  async function fetchData() {
    const url = repository
      ? `https://api.github.com/repos/${repository}/notifications?per_page=100`
      : "https://api.github.com/notifications?per_page=100";

    const response = await api.fetch(url, {
      headers: { Authorization: `Bearer ${token}` },
    });

    if (!response.ok || !response.json) {
      throw new Error(
        `Failed to fetch GitHub notifications (HTTP ${response.status})`,
      );
    }

    const items = response.json
      .map((item) => {
        const itemUrl = item.subject.url
          ? item.subject.url
              .replace("api.github.com/repos", "github.com")
              .replace("/pulls/", "/pull/")
              .replace("/issues/", "/issues/")
          : null;

        if (!itemUrl) {
          return null;
        }

        return {
          id: item.id,
          title: item.subject.title,
          subtitle: item.repository.full_name,
          url: itemUrl,
          timestamp: item.updated_at,
          notify: true,
        };
      })
      .filter(Boolean);

    api.emit(items);
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};
id: codytseng/github-notifications
version: 1.0.0
name: GitHub Notifications
description: |
  Get GitHub notifications in your menu bar.
  Supports filtering by repository.
author: codytseng
author_url: https://github.com/codytseng
category: Developer
tags:
  - github
  - notifications
  - developer

config:
  - key: GITHUB_TOKEN
    name: GitHub Token
    type: secret
    required: true
    description: "Personal access token from GitHub Settings"
  - key: REPOSITORY
    name: Repository
    type: string
    required: false
    description: "Optional: Filter by repository (format: owner/repo)"
module.exports = async (api) => {
  const token = api.config.get("GITHUB_TOKEN");
  const repository = api.config.get("REPOSITORY");

  async function fetchData() {
    const url = repository
      ? `https://api.github.com/repos/${repository}/notifications?per_page=100`
      : "https://api.github.com/notifications?per_page=100";

    const response = await api.fetch(url, {
      headers: { Authorization: `Bearer ${token}` },
    });

    if (!response.ok || !response.json) {
      throw new Error(
        `Failed to fetch GitHub notifications (HTTP ${response.status})`,
      );
    }

    const items = response.json
      .map((item) => {
        const itemUrl = item.subject.url
          ? item.subject.url
              .replace("api.github.com/repos", "github.com")
              .replace("/pulls/", "/pull/")
              .replace("/issues/", "/issues/")
          : null;

        if (!itemUrl) {
          return null;
        }

        return {
          id: item.id,
          title: item.subject.title,
          subtitle: item.repository.full_name,
          url: itemUrl,
          timestamp: item.updated_at,
        };
      })
      .filter(Boolean);

    api.emit(items);
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};

相關資料來源