-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwikiupdate.sh
More file actions
108 lines (91 loc) · 2.06 KB
/
wikiupdate.sh
File metadata and controls
108 lines (91 loc) · 2.06 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
DIRNAME=$(basename "$(pwd)");
SHORTREPOKEY=$(echo "$DIRNAME" | tr '[:upper:]' '[:lower:]');
access_token='${{ secrets.SYNCTOKEN }}'
wiki_folder='${{ github.event.repository.name }}'
# make folder and file so wiki is autoupdated
[[ ! -d "./.github/workflows/ " ]] && mkdir -p ./.github/workflows/
cat << EOL > ./.github/workflows/updatewiki.yml
---
on:
push:
branches:
- "master"
pull_request:
branches:
- "master"
name: Update Wiki
jobs:
udpate-wiki:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Wiki Sync
uses: LillyWho/ghaction-wiki-sync-custom@v1.0
with:
username: 14paxton
access_token: $access_token
wiki_folder: $wiki_folder
commit_message: "wikisync"
commit_username: "14paxton"
commit_email: "26972590+14paxton@users.noreply.github.com "
EOL
# make folder for wiki to update from and move markdown files to new folder
[[ -d ./wiki/ ]] && mv wiki "$DIRNAME"
[[ ! -d ./"$DIRNAME" ]] && mkdir -p "$DIRNAME"
if [[ -n *.md(#qN) ]]; then
mv *.md ./"$DIRNAME"/
fi
cd "$DIRNAME"
# create frontmatter index file for side nav to key on
[[ -d ./$DIRNAME/ ]] && cd "$DIRNAME"
#[[ ! -f ./$DIRNAME ]] && touch "$DIRNAME".md
cat << EOL > "$DIRNAME".md
---
title: $DIRNAME
layout: default
permalink: $DIRNAME/
category: $DIRNAME
has_children: true
share: true
shortRepo:
- $SHORTREPOKEY
- default
---
# [REPO](https://github.com/14paxton/$DIRNAME)
EOL
# get files and add frontmatter for side nav tree
for st in $(find "$(PWD)" -type f); do
FILENAME=${$(basename "$st")%.*}
PERMALINK=$DIRNAME/$FILENAME
if [[ "$FILENAME" != "$DIRNAME" && ! $(grep -R "has_children" "$FILENAME".md) ]] then;
ex "$st" << eof
1 insert
---
title: $FILENAME
permalink: $PERMALINK
category: $DIRNAME
parent: $DIRNAME
layout: default
has_children: false
share: true
shortRepo:
- $SHORTREPOKEY
- default
---
<br/>
<details markdown="block">
<summary>
Table of contents
</summary>
{: .text-delta }
1. TOC
{:toc}
</details>
<br/>
***
<br/>
.
xit
eof
fi
done;