Skip to content

Commit

Permalink
Generate dropdown of versions
Browse files Browse the repository at this point in the history
This will show a nice dropdown to select other versions of the
documentation.

Signed-off-by: Chmouel Boudjnah <[email protected]>
  • Loading branch information
chmouel authored and savitaashture committed Jul 3, 2023
1 parent 43320b2 commit 289f39a
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 13 deletions.
17 changes: 14 additions & 3 deletions .tekton/generate-coverage-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,21 @@ spec:
set -eux
git config --global --add safe.directory $(workspaces.source.path)
ssa=$(git rev-parse --short HEAD)
bash hack/generate-releaseyaml.sh > release.k8s.yaml
env TARGET_OPENSHIFT=true bash hack/generate-releaseyaml.sh > release.yaml
bash hack/generate-releaseyaml.sh >release.k8s.yaml
env TARGET_OPENSHIFT=true bash hack/generate-releaseyaml.sh >release.yaml
allversions=$(
echo -n "nightly,stable,"
for i in $(git tag -l | grep '^v' | sort -rn); do echo -n "$i,"; done | sed 's/,$//'
)
set +x # Do not show TOKEN in logs
python hack/upload-file-to-github.py --message "Release yaml generated from {{repo_url}}/commit/{{revision}}" --from-ref refs/heads/main --to-ref refs/heads/nightly --owner-repository openshift-pipelines/pipelines-as-code --token ${HUB_TOKEN} -f release.k8s.yaml:release.k8s.yaml -f release.yaml:release.yaml -f nightly:docs/content/VERSION -f "nightly-$ssa-$(date +%Y%m%d):pkg/params/version/version.txt"
python hack/upload-file-to-github.py --message "Release yaml generated from {{repo_url}}/commit/{{revision}}" \
--from-ref refs/heads/main --to-ref refs/heads/nightly \
--owner-repository openshift-pipelines/pipelines-as-code --token ${HUB_TOKEN} \
-f release.k8s.yaml:release.k8s.yaml \
-f release.yaml:release.yaml \
-f nightly:docs/content/VERSION \
-f ${allversions}:docs/content/ALLVERSIONS \
-f "nightly-$ssa-$(date +%Y%m%d):pkg/params/version/version.txt"
workspaces:
- name: source
workspaces:
Expand Down
12 changes: 11 additions & 1 deletion .tekton/release-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,18 @@ spec:
./hack/generate-releaseyaml.sh > /tmp/release.k8s.yaml
env TARGET_OPENSHIFT=true bash hack/generate-releaseyaml.sh > /tmp/release.yaml
msg="pac release ${version} on branch ${target}"
# fetch all versions and generate a file for the dropdown menu to select the version documentation
allversions=$(echo -n "nightly,stable,";for i in $(git tag -l|grep '^v'|sort -rn);do echo -n "$i,";done|sed 's/,$//')
set +x
echo python hack/upload-file-to-github.py --message "Release yaml generated for ${msg}" --owner-repository openshift-pipelines/pipelines-as-code --token "TOKEN" --to-ref=refs/heads/${target} --from-ref=refs/tags/${version} -f release.k8s.yaml:release.k8s.yaml -f release.yaml:release.yaml -f ${TARGET_BRANCH}:docs/content/VERSION -f "${version}:pkg/params/version/version.txt"
echo python hack/upload-file-to-github.py \
--message "Release yaml generated for ${msg}" \
--owner-repository openshift-pipelines/pipelines-as-code --token "TOKEN" \
--to-ref=refs/heads/${target} --from-ref=refs/tags/${version} \
-f release.k8s.yaml:release.k8s.yaml \
-f release.yaml:release.yaml \
-f ${TARGET_BRANCH}:docs/content/VERSION \
-f ${allversions}:docs/content/ALLVERSIONS \
-f "${version}:pkg/params/version/version.txt"
python hack/upload-file-to-github.py --message "Release yaml generated for ${msg}" --owner-repository openshift-pipelines/pipelines-as-code --token ${HUB_TOKEN} --to-ref=refs/heads/${target} --from-ref=refs/tags/${version} -f /tmp/release.k8s.yaml:release.k8s.yaml -f /tmp/release.yaml:release.yaml -f ${TARGET_BRANCH}:docs/content/VERSION -f "${version}:pkg/params/version/version.txt"
set -x
done
Expand Down
1 change: 0 additions & 1 deletion docs/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ html,
body {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !default;
}

40 changes: 32 additions & 8 deletions docs/layouts/partials/docs/footer.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
<div class="flex flex-wrap justify-between">

{{ if fileExists "ALLVERSIONS" }}
{{ $versions := os.ReadFile "ALLVERSIONS" }}
{{ $version := "nightly"}}
{{ if fileExists "VERSION" }}
{{ $version := os.ReadFile "VERSION" }}
<div>
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/tree/{{ trim $version "\n" }}" target="_blank" rel="noopener">
<img src="{{ "svg/version.svg" | relURL }}" class="book-icon" alt="Calendar" />
<span>{{ $version | title }}</span>
</a>
</div>
{{ $version = os.ReadFile "VERSION" | strings.TrimLeft "\n" | strings.TrimRight "\n" }}
{{ end }}
{{ $splitted := split $versions "," }}
<select name="version" id="version" onchange="javascript:handleVersion(this)">
{{ range $splitted }}
{{ $trimmed := strings.TrimLeft " " . | strings.TrimRight " " }}
{{ if ne $trimmed $version }}
<option value="{{ $trimmed }}">{{$trimmed}}</option>
{{ else }}
<option selected value="{{ $trimmed }}">{{$trimmed}}</option>
{{ end }}
{{ end }}
</select>
<script type="text/javascript">
function handleVersion(elm)
{
if (elm.value == "nightly")
{
window.location = "https://nightly.pipelines-as-code.pages.dev"
return
} else if (elm.value == "stable")
{
window.location = "https://pipelinesascode.com"
return
}
var v = elm.value.replace(/\./g, "-");
window.location = "https://release-" + v + ".pipelines-as-code.pages.dev/"
}
</script>
{{ end }}

{{ if and .GitInfo .Site.Params.BookRepo }}
Expand Down

0 comments on commit 289f39a

Please sign in to comment.