-
-
Notifications
You must be signed in to change notification settings - Fork 120
/
update-wiki.sh
59 lines (43 loc) · 1.24 KB
/
update-wiki.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
set -eu
cd ./src
echo "Restore project"
dotnet restore
echo "Restore local tools"
dotnet tool restore
echo "Build project"
dotnet build --configuration Release --no-restore
TMP_WORK_DIR="tmp-$GITHUB_SHA"
WIKI_REPO_DIR="wiki-repo"
WIKI_UPDATE_DIR="wiki-update"
echo Create working directory
mkdir -p -- $TMP_WORK_DIR
echo Going to $TMP_WORK_DIR
cd $TMP_WORK_DIR
echo Creating wiki folders
mkdir -p -- $WIKI_REPO_DIR
mkdir -p -- $WIKI_UPDATE_DIR
echo Cloning wiki
git clone https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.wiki.git $WIKI_REPO_DIR
echo "Create wiki"
cd ..
dotnet netdocgen $ASSEMBLY_PATH -o "$TMP_WORK_DIR/$WIKI_UPDATE_DIR"
cd $TMP_WORK_DIR
echo "Copying edited wiki"
cp -R "$WIKI_REPO_DIR/.git" "$WIKI_UPDATE_DIR/"
echo Go into the repo
cd $WIKI_UPDATE_DIR
echo Prepare commit
#Get commit details
author=`git log -1 --format="%an"`
email=`git log -1 --format="%ae"`
message=`git log -1 --format="%s"`
git config --local user.email "$email"
git config --local user.name "$author"
git add .
if git diff-index --quiet HEAD; then
echo "Nothing changed"
exit 0
fi
echo "Pushing changes to wiki"
git commit -m "$message" && git push "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.wiki.git"