Skip to content

Instantly share code, notes, and snippets.

@luboszima
Last active August 25, 2025 16:42
Show Gist options
  • Select an option

  • Save luboszima/0a55806ee45011bd7686662b9f2fdcd1 to your computer and use it in GitHub Desktop.

Select an option

Save luboszima/0a55806ee45011bd7686662b9f2fdcd1 to your computer and use it in GitHub Desktop.
glance wiget for Github Notifications
- type: custom-api
title: GitHub Notifications
url: https://api.github.com/notifications?all=true&per_page=20
headers:
Authorization: Bearer ${GITHUB_TOKEN}
Accept: application/vnd.github+json
template: |
<ul class="list list-gap-14 collapsible-container" data-collapse-after="6">
{{ range .JSON.Array "" }}
{{ $url := concat (.String "repository.html_url") "/actions" }}
{{ if ne (.String "subject.url") "" }}
{{
$notification := newRequest (.String "subject.url")
| withHeader "Authorization" "Bearer ${GITHUB_TOKEN}"
| getResponse
}}
{{ if eq $notification.Response.StatusCode 200 }}
{{ $url = $notification.JSON.String "html_url" }}
{{ else }}
{{ $url = (.String "subject.url") | replaceMatches "repos\\/" "" | replaceMatches "api\\." "" | replaceAll "pulls" "pull" }}
{{ end }}
{{ end }}
<li>
<a href="{{ $url }}" class="size-title-dynamic {{ if .Bool "unread" }}color-primary-if-not-visited{{ else }}negative-color{{ end }}" target="_blank" rel="noreferrer">{{ .String "subject.title" }}</a>
<ul class="list-horizontal-text flex-nowrap">
<li class="min-width-0" {{ .String "updated_at" | parseTime "rfc3339" | toRelativeTime }}></li>
<li class="min-width-0"><a target="_blank" href="{{ $url }}">{{ .String "repository.full_name" }}</a></li>
</ul>
</li>
{{ end }}
</ul>
@luboszima
Copy link
Author

luboszima commented Jul 13, 2025

  1. create classic token with Notifications permission (read only): https://github.com/settings/tokens
  2. in your glance app setup new env variable (possibly in docker-compose.yml): GITHUB_TOKEN value will be your token
  3. Add to your glance dashboard yml definition custom-api from this gist.

This widget is created to be part of small column.

- name: Home
  columns:
    - size: small
      widgets:
        - type: custom-api
          title: GitHub Notifications
          url: https://api.github.com/notifications?all=true&per_page=20
          headers:
            Authorization: Bearer ${GITHUB_TOKEN}
            Accept: application/vnd.github+json
          template: |
            <ul class="list list-gap-14 collapsible-container" data-collapse-after="6">
            {{ range .JSON.Array "" }}

              {{ $url := concat (.String "repository.html_url") "/actions" }}

              {{ if ne (.String "subject.url") "" }}
                {{
                  $notification := newRequest (.String "subject.url")
                    | withHeader "Authorization" "Bearer ${GITHUB_TOKEN}"
                    | getResponse
                }}

                {{ if eq $notification.Response.StatusCode 200 }}
                  {{ $url = $notification.JSON.String "html_url" }}
                {{ else }}
                  {{ $url = (.String "subject.url") | replaceMatches "repos\\/" "" | replaceMatches "api\\." "" | replaceAll "pulls" "pull" }}
                {{ end }}
              {{ end }}
              <li>
                <a href="{{ $url }}" class="size-title-dynamic {{ if .Bool "unread" }}color-primary-if-not-visited{{ else }}negative-color{{ end }}" target="_blank" rel="noreferrer">{{ .String "subject.title" }}</a>
                <ul class="list-horizontal-text flex-nowrap">
                  <li class="min-width-0" {{ .String "updated_at" | parseTime "rfc3339" | toRelativeTime }}></li>
                  <li class="min-width-0"><a target="_blank" href="{{ $url }}">{{ .String "repository.full_name" }}</a></li>
                </ul>
              </li>
            {{ end }}
            </ul>
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment