-
Notifications
You must be signed in to change notification settings - Fork 3
58 lines (56 loc) · 2.2 KB
/
parse.yml
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
name: Parser
on:
push:
branches:
- main
- master
jobs:
parse_files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name : "Install Python dependencies"
run : pip install Markdown reportlab selenium weasyprint==53.0 PyPDF2
- name: "Parse markdown subjects"
run: |
for file in $(ls -d */)
do
if [ ! -d "$file/subject" ]; then
echo "::error file=$file,title="No subject folder."::$file"
continue
fi
if [ ! -f "$file/subject/data.txt" ]; then
echo "::error file=$file/subject,title="No subject data.txt."::$file/subject"
continue
fi
data=$(cat $file/subject/data.txt)
stable=$(echo "$data" | cut -d$'\n' -f4)
if [ "$stable" = "stable" ]; then
echo "::notice file=$file/mouli/data.txt,title="Marked as stable"::$file/mouli/data.txt"
continue
fi
title=$(echo "$data" | cut -d$'\n' -f1)
if [ -z "$title" ]; then
echo "::error file=$file/subject/data.txt,title="No title."::$file/subject/data.txt"
continue
fi
version=$(echo "$data" | cut -d$'\n' -f2)
if [ -z "$version" ]; then
echo "::error file=$file/subject/data.txt,title="No version."::$file/subject/data.txt"
continue
fi
campus=$(echo "$data" | cut -d$'\n' -f3)
if [ -z "$campus" ]; then
echo "::error file=$file/subject/data.txt,title="No campus."::$file/subject/data.txt"
continue
fi
md=$(ls $file/subject/*.md | head -n1)
if [ -z "$md" ]; then
echo "::error file=$file/subject,title="No markdown file."::$file/subject"
continue
fi
cd .github/workflows/parser && python3 cc_subjects.py "../../../$md" "$title" "$version" "$campus" && cd ../../..
done
- uses: EndBug/add-and-commit@v9
with:
default_author: github_actions