|
| 1 | +{{/* |
| 2 | + |
| 3 | +@param {string} [0/team] Netlify App team name. |
| 4 | +@param {string} [1/repoURL] The repository URL, optional. Defaults to site param `github_repo`. |
| 5 | + |
| 6 | +*/ -}} |
| 7 | + |
| 8 | +{{ $scName := "site-build-info/netlify" -}} |
| 9 | + |
| 10 | +{{ $team := .Get 0 | default (.Get "team") -}} |
| 11 | + |
| 12 | +{{ if not $team -}} |
| 13 | + {{ warnf "%s: shortcode %q: parameter 0 ('team') is missing" .Position $scName -}} |
| 14 | +{{ end -}} |
| 15 | + |
| 16 | +{{ $repoURL := .Get 1 | default (.Get "repoURL") | default (.Page.Param "github_repo") -}} |
| 17 | + |
| 18 | +{{ if not $repoURL -}} |
| 19 | + {{ $msg := add |
| 20 | + "parameter 1 ('repoURL') is missing and " |
| 21 | + "site param 'github_repo' is not defined." |
| 22 | + -}} |
| 23 | + {{ warnf "%s: shortcode %q: %s" .Position $scName $msg -}} |
| 24 | +{{ else if hasSuffix $repoURL "/" -}} |
| 25 | + {{ $repoURL = strings.TrimSuffix $repoURL "/" -}} |
| 26 | +{{ end -}} |
| 27 | + |
| 28 | +{{ $branch := os.Getenv "BRANCH" -}} |
| 29 | +{{ $buildID := os.Getenv "BUILD_ID" -}} |
| 30 | +{{ $commitRef := os.Getenv "COMMIT_REF" -}} |
| 31 | +{{ $deployID := os.Getenv "DEPLOY_ID" -}} |
| 32 | +{{ $isNetlifyBuilt := os.Getenv "NETLIFY" | default false -}} |
| 33 | +{{ $isPR := os.Getenv "PULL_REQUEST" -}} |
| 34 | +{{ $reviewID := os.Getenv "REVIEW_ID" -}} |
| 35 | +{{ $now := now -}} |
| 36 | + |
| 37 | +Netlify build information: |
| 38 | + |
| 39 | +| Attribute | Value | |
| 40 | +|---|---| |
| 41 | +Netlify built | `{{ $isNetlifyBuilt }}` |
| 42 | +{{/**/ -}} |
| 43 | + |
| 44 | +{{/*Don't show timestamp for local builds to avoid affecting site diffs. */ -}} |
| 45 | +{{ with $isNetlifyBuilt -}} |
| 46 | + Date/time[^date] | {{ $now.Format "2006-01-02 15:04 MST" }}[^local-time] |
| 47 | +{{ end -}} |
| 48 | +{{/**/ -}} |
| 49 | + |
| 50 | +{{ with $buildID -}} |
| 51 | + ID | `{{.}}` |
| 52 | +{{ end -}} |
| 53 | +{{/**/ -}} |
| 54 | + |
| 55 | +{{ with $deployID -}} |
| 56 | + Deploy log | [{{ . }}](https://app.netlify.com/teams/{{ $team }}/builds/{{ . }}) |
| 57 | +{{ end -}} |
| 58 | +{{/**/ -}} |
| 59 | + |
| 60 | +{{ with $reviewID -}} |
| 61 | + Build context | |
| 62 | + {{- if $isPR -}} |
| 63 | + [PR #{{ . }}]({{ $repoURL }}/pull/{{ . }}) |
| 64 | + {{ else -}} |
| 65 | + merge `{{ . }}` |
| 66 | + {{ end -}} |
| 67 | +{{ end -}} |
| 68 | +{{/**/ -}} |
| 69 | + |
| 70 | +Deploy context | {{ os.Getenv "CONTEXT" | default "local" }} |
| 71 | +{{/**/ -}} |
| 72 | + |
| 73 | +{{ with $commitRef -}} |
| 74 | + Commit | [@{{substr . 0 7 }}]({{ $repoURL }}/commit/{{ . }}) |
| 75 | +{{ end -}} |
| 76 | +{{/**/ -}} |
| 77 | + |
| 78 | +{{ with $branch -}} |
| 79 | + Branch | `{{ . }}` |
| 80 | +{{ end -}} |
| 81 | +{{/*End of table*/}} |
| 82 | + |
| 83 | +[^date]: Approximate build timestamp. |
| 84 | +[^local-time]: In your timezone: <span id="local-time">unknown</span>. |
| 85 | + |
| 86 | +<script> |
| 87 | +document.addEventListener("DOMContentLoaded", function() { |
| 88 | + var options = { hour: '2-digit', hour12: false, minute: '2-digit', timeZoneName: 'short' }; |
| 89 | + var buildDate = new Date("{{ $now.Format "2006-01-02T15:04:05Z07:00" }}"); |
| 90 | + document.getElementById("local-time").innerText = buildDate.toLocaleString(undefined, options); |
| 91 | +}); |
| 92 | +</script> |
0 commit comments