forked from covid19india/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sh
79 lines (56 loc) · 1.58 KB
/
main.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
set -eu
repo_uri="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
remote_name="origin"
main_branch="master"
gh_pages_branch="gh-pages"
git config user.name "$GITHUB_ACTOR"
git config user.email "${GITHUB_ACTOR}@bots.github.com"
git checkout "$gh_pages_branch"
mkdir tmp
mkdir tmp/resources
mkdir tmp/v2
mkdir tmp/updatelog
cp ./data.json ./tmp/data_prev.json
cp ./raw_data1.json ./tmp
cp ./deaths_recoveries1.json ./tmp
cp -r ./updatelog ./tmp
cp -r ./csv ./tmp
git checkout "$main_branch"
node src/sheet-to-json_generic.js
cp README.md tmp/
cp -r documentation/ tmp/
cp -r projects/ tmp/
node src/sheets-to-csv.js
node src/states_daily_to_csv.js
node src/district_data_generator.js
# node src/concat_data.js
# node src/split_raw_data.js
# node src/snapshot_zones.js
# node src/generate_districts_daily.js
node src/generate_locale.js
# node src/ultimate_parser.js
# pip3 install --quiet -r requirements.txt
# python3 src/geocoder.py
python3 src/parser_v3.py
python3 src/parser_v4.py
# python3 src/build_raw_data.py
node src/sanity_check.js
node src/generate_activity_log.js
git checkout "$gh_pages_branch"
rm tmp/data_prev.json
cp -r tmp/* .
rm -r tmp/
git add .
set +e # Grep succeeds with nonzero exit codes to show results.
if git status | grep 'new file\|modified'
then
set -e
git commit -am "data updated on - $(date)"
git remote set-url "$remote_name" "$repo_uri" # includes access token
git push --force-with-lease "$remote_name" "$gh_pages_branch"
else
set -e
echo "No changes since last run"
fi
echo "finish"