-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathimport-ai-lab-samples
executable file
·42 lines (33 loc) · 1.1 KB
/
import-ai-lab-samples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR=$(realpath $SCRIPTDIR/..)
SKELETON_DIR=$ROOT_DIR/skeleton
TEMPLATE_DIR=$ROOT_DIR/templates
TEMPLATE_TECHDOC_TYPE=app
REPO="${SAMPLE_REPO:-https://github.com/redhat-ai-dev/ai-lab-samples}"
BRANCH="${SAMPLE_BRANCH:-main}"
DIRNAME=$(basename $REPO)
mkdir -p $SCRIPTDIR/samples
SAMPLE_DIR=$SCRIPTDIR/samples/$DIRNAME
if [ -d $SAMPLE_DIR ]; then
(cd $SAMPLE_DIR; git pull 2>&1 > /dev/null)
else
(cd $SCRIPTDIR/samples; git clone $REPO 2>&1 > /dev/null)
fi
(cd $SAMPLE_DIR; git checkout $BRANCH; git pull)
cd $SAMPLE_DIR
# get readme to source component doc
cp -r $SAMPLE_DIR/README.md $SKELETON_DIR/techdoc/docs/source-component.md
for f in */; do
if [ -d "$f" ]; then
# $f is a directory
SAMPLENAME=$(basename $f)
DEST=$TEMPLATE_DIR/$SAMPLENAME
rm -rf $DEST
mkdir -p $DEST
cp -r $SAMPLE_DIR/$SAMPLENAME $DEST/content
source $SCRIPTDIR/util
apply-configurations $DEST $SAMPLENAME $TEMPLATE_TECHDOC_TYPE
fi
done
rm -rf $SCRIPTDIR/samples