Skip to content

Commit 88861f7

Browse files
Merge pull request #8 from jordangarrison/gh-links
feat: add GitHub links to pipeline view
2 parents 6508e57 + b0c6685 commit 88861f7

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

lib/greenlight_web/live/pipeline_live.ex

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ defmodule GreenlightWeb.PipelineLive do
1616
nodes: [],
1717
edges: [],
1818
workflow_runs: [],
19-
page_title: "#{owner}/#{repo} - #{String.slice(sha, 0, 7)}"
19+
page_title: "#{owner}/#{repo} - #{String.slice(sha, 0, 7)}",
20+
github_url: "https://github.com/#{owner}/#{repo}/commit/#{sha}",
21+
github_label: String.slice(sha, 0, 7)
2022
)
2123

2224
WideEvent.add(
@@ -56,7 +58,14 @@ defmodule GreenlightWeb.PipelineLive do
5658
pr = Enum.find(pulls, fn p -> p.number == String.to_integer(number) end)
5759

5860
if pr do
59-
mount(%{"owner" => owner, "repo" => repo, "sha" => pr.head_sha}, session, socket)
61+
{:ok, socket} =
62+
mount(%{"owner" => owner, "repo" => repo, "sha" => pr.head_sha}, session, socket)
63+
64+
{:ok,
65+
assign(socket,
66+
github_url: "https://github.com/#{owner}/#{repo}/pull/#{number}",
67+
github_label: "PR ##{number}"
68+
)}
6069
else
6170
{:ok,
6271
socket
@@ -79,7 +88,14 @@ defmodule GreenlightWeb.PipelineLive do
7988
run = Enum.find(runs, fn r -> r.head_sha end)
8089

8190
if run do
82-
mount(%{"owner" => owner, "repo" => repo, "sha" => run.head_sha}, session, socket)
91+
{:ok, socket} =
92+
mount(%{"owner" => owner, "repo" => repo, "sha" => run.head_sha}, session, socket)
93+
94+
{:ok,
95+
assign(socket,
96+
github_url: "https://github.com/#{owner}/#{repo}/releases/tag/#{tag}",
97+
github_label: tag
98+
)}
8399
else
84100
{:ok,
85101
socket
@@ -131,6 +147,23 @@ defmodule GreenlightWeb.PipelineLive do
131147
</.link>
132148
<span class="text-[var(--gl-border)]">/</span>
133149
<span class="text-[var(--gl-accent)]">{String.slice(@sha, 0, 7)}</span>
150+
<span class="text-[var(--gl-border)]">·</span>
151+
<a
152+
href={@github_url}
153+
target="_blank"
154+
rel="noopener noreferrer"
155+
class="inline-flex items-center gap-1.5 text-[var(--gl-text-muted)] hover:text-[var(--gl-accent)] transition-colors"
156+
>
157+
<svg
158+
viewBox="0 0 16 16"
159+
fill="currentColor"
160+
class="w-4 h-4"
161+
aria-hidden="true"
162+
>
163+
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" />
164+
</svg>
165+
{@github_label}
166+
</a>
134167
</div>
135168
<h1 class="text-3xl font-bold text-white uppercase tracking-wider">
136169
Pipeline

0 commit comments

Comments
 (0)