Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Docs: Update internal versions & Automate future updates #4558

Merged
merged 6 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/documentation-versioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: documentation-versions

on:
release:
types: [published]

jobs:
update-docs-internal-versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Update internal-versions.json
run: |
cd website
if [ -e yarn.lock ]; then
yarn install --frozen-lockfile
elif [ -e package-lock.json ]; then
npm ci
else
npm i
fi
npm run add-version
- name: Create Pull Request
id: cpr
uses: peter-evans/[email protected]
with:
commit-message: Update Docs Versions
delete-branch: true
title: Update website docs version following release
body: |
- Auto-generated
labels: |
ready for review
draft: false
- name: Check output
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
27 changes: 27 additions & 0 deletions website/add-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -e
set -o pipefail

echo "Determining version Label & Tag"

# GITHUB_EVENT_PATH points to json containing event data. This contains the github release object
# See https://developer.github.com/webhooks/event-payloads/#release
versionLabel=$(jq -r '.release.name' $GITHUB_EVENT_PATH)
versionSha=$(jq -r '.release.tag_name' $GITHUB_EVENT_PATH)
showVersionInDropDown=true
internalVersionsFile="internal-versions.json"

echo Adding the following as latest docs version
echo "Label : $versionLabel"
echo "Tag/Sha : $versionSha"
echo "Show In Dropdown : $showVersionInDropDown"

interalVersion=$versionLabel:$versionSha:$showVersionInDropDown
echo "New Version : $interalVersion"

# Write to temp env var. Not sure why, but a simple `> $internalVersionsFile` wipes out content
res=$(jq --arg argval $interalVersion -r '. |= [$argval] + .' $internalVersionsFile)
echo "$res" > $internalVersionsFile

echo "Result :"
cat $internalVersionsFile
3 changes: 2 additions & 1 deletion website/build-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function cleanUpBefore() (
function gitClone() (
rurl="$1" localdir="$2"
echo "Cloning from $rurl into $localdir"
git clone --depth 1 --no-single-branch $rurl $localdir
# git clone --depth 1 --no-single-branch $rurl $localdir
git clone $rurl $localdir
pushd $localdir/website > /dev/null
npm install
popd > /dev/null
Expand Down
3 changes: 2 additions & 1 deletion website/internal-versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[
"4.0.0:docs-versioning:true"
"4.0.1:372682177452d8d:true",
"4.0.0:372682177452d8d:true"
]
1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"deploy": "./deploy.sh",
"version": "docusaurus docs:version",
"versions": "./build-versions.sh",
"add-version": "./add-version.sh",
"docusaurus": "docusaurus",
"serve": "docusaurus serve"
},
Expand Down