Skip to content

Commit

Permalink
ci(update-index.sh): Add a script to update docs/index.md
Browse files Browse the repository at this point in the history
Related: ocaml-sf#490

Co-authored-by: Erik Martin-Dorel <erik@martin-dorel.org>
  • Loading branch information
cesclass and erikmd committed Jun 30, 2022
1 parent b91050e commit c538200
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/update-index.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# This script updates 'docs/index.md' from 'README.md',
# and changes github.com/…/learn-ocaml/…/docs URLs to relative paths,
# so that github.io pages work independently of github.com src files.

srcdir=$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd)

readme=$(readlink -f "$srcdir/../README.md")
index=$(readlink -f "$srcdir/../docs/index.md")

if [[ ! -r "$readme" ]]
then
echo "Error: '$readme': file does not exist or is unreadable"
exit 1
fi

if [[ ! -w "$index" ]]
then
echo "Error: '$index': file does not exist or is not writable"
exit 1
fi

url="https://github.com/ocaml-sf/learn-ocaml/blob/master/docs"

sed -e "s;$url;.;g" "$readme" > "$index"

0 comments on commit c538200

Please sign in to comment.