|
| 1 | + |
| 2 | + |
| 3 | +```yaml |
| 4 | +- type: custom-api |
| 5 | + title: GitHub Actions |
| 6 | + url: https://api.github.com/repos/OWNER/REPO_NAME/actions/runs |
| 7 | + cache: 5m |
| 8 | + parameters: |
| 9 | + branch: develop |
| 10 | + exclude_pull_requests: true |
| 11 | + per_page: 6 |
| 12 | + headers: |
| 13 | + Authorization: Bearer ${GITHUB_TOKEN} |
| 14 | + Accept: application/vnd.github.v3+json |
| 15 | + User-Agent: Glance-Dashboard |
| 16 | + template: | |
| 17 | + <div class="github-repos"> |
| 18 | + <ul class="list list-gap-14 collapsible-container" data-collapse-after="2"> |
| 19 | + |
| 20 | + {{ range .JSON.Array "workflow_runs" }} |
| 21 | + {{ $rzt := .String "conclusion" }} |
| 22 | + <li> |
| 23 | + <a class="size-h3 color-primary-if-not-visited" href="{{ .String "html_url" }}">{{ .String "display_title" }}</a> |
| 24 | + <h3><a href="" target=""></a></h3> |
| 25 | + <p>{{ .String "description" }}</p> |
| 26 | + <ul class="list-horizontal-text"> |
| 27 | + <li data-popover-type="html" {{ .String "updated_at" | parseTime "rfc3339" | toRelativeTime }}></li> |
| 28 | + <li data-popover-type="html"><div data-popover-html="">{{ .String "actor.login" }}</div>{{ .String "name" }}</li> |
| 29 | + <li data-popover-type="html"><div data-popover-html="">{{ .String "status" }}</div> |
| 30 | + {{ if eq $rzt "success" }} |
| 31 | + <svg width="20" height="20" fill="var(--color-positive)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"> |
| 32 | + <path fill-rule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z" clip-rule="evenodd" /> |
| 33 | + </svg> |
| 34 | + {{ else }} |
| 35 | + <svg width="20" height="20" fill="var(--color-negative)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"> |
| 36 | + <path fill-rule="evenodd" d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" clip-rule="evenodd" /> |
| 37 | + </svg> |
| 38 | + {{ end }} |
| 39 | + </li> |
| 40 | + </ul> |
| 41 | + </li> |
| 42 | + {{ end }} |
| 43 | + </ul> |
| 44 | + </div> |
| 45 | +``` |
| 46 | +
|
| 47 | +## Environment variables |
| 48 | +
|
| 49 | +- `GITHUB_TOKEN`: Your GitHub Personal Access Token, you can create a token from Github settings. Navigate to _GitHub Settings > Developer settings > Personal access tokens > Tokens (classic)_, and create a new token with _notifications_ scope selected. |
| 50 | + |
| 51 | +## Other notes |
| 52 | + |
| 53 | +- Modify the URL to point to your own repository by changing `OWNER/REPO_NAME`. |
| 54 | +- Pass parameters like `branch`, `status` and other from the [GitHub Actions API](https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository) as needed. |
| 55 | +- Edit `data-collapse-after` value to show more or fewer items before collapsing. |
0 commit comments