-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathmain.sh
61 lines (40 loc) · 1.18 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
#!/bin/bash
echo "main.sh start"
set -eu
repo_uri="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
remote_name="origin"
main_branch="main"
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
cp -r ./updatelog ./tmp
cp -r ./csv ./tmp
cp v4/min/data.min.json ./tmp/data-old.min.json
cp ./csv/latest/state_wise.csv ./tmp/state_wise_prev
git checkout "$main_branch"
cp README.md tmp/
cp -r documentation/ tmp/
node src/sheets-to-csv.js
python3 src/parser_v4.py
python3 src/generate_activity_log.py
# node src/sanity_check.js # need rewrite with new json
git checkout "$gh_pages_branch"
rm tmp/data-old.min.json
rm tmp/state_wise_prev
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 "main.sh end"