Skip to content

Commit

Permalink
[CI] Publish site-build info under /site (#3111)
Browse files Browse the repository at this point in the history
  • Loading branch information
chalin committed Jul 31, 2023
1 parent d994dfc commit c87dcad
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 2 deletions.
7 changes: 7 additions & 0 deletions content/en/site/_index.md
@@ -0,0 +1,7 @@
---
title: Website information
likeTitle: Site info
cascade: { type: docs }
---

{{% site-build-info %}}
14 changes: 12 additions & 2 deletions hugo.yaml
@@ -1,3 +1,4 @@
# cSpell:ignore docsy goldmark netlify wordmark
baseURL: https://opentelemetry.io
title: &title OpenTelemetry
description: &desc The OpenTelemetry Project Site
Expand All @@ -15,7 +16,7 @@ languages:
title: *title
description: *desc
imaging:
resampleFilter: CatmullRom
resampleFilter: CatmullRom # cspell:disable-line
quality: 75
anchor: smart

Expand Down Expand Up @@ -131,6 +132,9 @@ params:
desc: >-
Important information on how to represent your personal or corporate
contributions or participation in the OpenTelemetry project.
- name: Site-build info
url: /site/
icon: fa-solid fa-hammer

logos:
hero: opentelemetry-horizontal-color.png
Expand Down Expand Up @@ -159,7 +163,7 @@ params:
icon: far fa-envelope

fonts:
- name: Noto Sans
- name: Noto Sans # cspell:disable-line
sizes: [300, 400, 600, 700]
type: sans_serif

Expand All @@ -175,6 +179,12 @@ services:
# https://github.com/open-telemetry/opentelemetry.io/issues/1626.
id: UA-00000000-0 # TODO: switch to G-0000000000 once we get confirmation that it's ok to do so

security:
funcs: # cspell:disable-line
getenv: # cspell:disable-line
# Netlify build env var
- ^(BRANCH|BUILD_ID|COMMIT_REF|CONTEXT|DEPLOY_ID|NETLIFY|PULL_REQUEST|REVIEW_ID)$

module:
mounts:
- source: content/en
Expand Down
57 changes: 57 additions & 0 deletions layouts/shortcodes/site-build-info.md
@@ -0,0 +1,57 @@
{{/* cSpell:ignore getenv substr */ -}}

{{ $branch := os.Getenv "BRANCH" -}}
{{ $buildID := os.Getenv "BUILD_ID" -}}
{{ $commitRef := os.Getenv "COMMIT_REF" -}}
{{ $deployID := os.Getenv "DEPLOY_ID" -}}
{{ $isNetlifyBuilt := os.Getenv "NETLIFY" | default false -}}
{{ $isPR := os.Getenv "PULL_REQUEST" -}}
{{ $reviewID := os.Getenv "REVIEW_ID" -}}

Netlify build information:

| Attribute | Value |
|---|---|
Netlify built | `{{ $isNetlifyBuilt }}`
{{/* */ -}}

{{/* Don't show timestamp for local builds to avoid affecting site diffs. */ -}}
{{ with $isNetlifyBuilt -}}
Date/time[^date] | {{ now.Format "2006-01-02 15:04" }}
{{ end -}}
{{/* */ -}}

{{ with $buildID -}}
ID | `{{.}}`
{{ end -}}
{{/* */ -}}

{{ with $deployID -}}
Deploy log | [{{ . }}](https://app.netlify.com/teams/opentelemetry/builds/{{ . }})
{{ end -}}
{{/* */ -}}

{{ with $reviewID -}}
Build context |
{{- if $isPR -}}
[PR #{{ . }}](https://github.com/open-telemetry/opentelemetry.io/pull/{{ . }})
{{ else -}}
merge `{{ . }}`
{{ end -}}
{{ end -}}
{{/* */ -}}

Deploy context | {{ os.Getenv "CONTEXT" | default "local" }}
{{/* */ -}}

{{ with $commitRef -}}
Commit | [@{{substr . 0 7 }}](https://github.com/open-telemetry/opentelemetry.io/commit//{{ . }})
{{ end -}}
{{/* */ -}}

{{ with $branch -}}
Branch | `{{ . }}`
{{ end -}}
{{/* End of table */}}

[^date]: Approximate build timestamp.

0 comments on commit c87dcad

Please sign in to comment.