forked from covid19india/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpushthejson
82 lines (61 loc) · 1.73 KB
/
pushthejson
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
#!/usr/bin/env bash
set -eu
# # Add a switch to pause updates from sheet
# RUN_STATUS="Play"
# if [ $RUN_STATUS == "Pause" ]
# then
# echo "Actions are paused. Check pushthejson script to enable."
# exit
# fi
repo_uri="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
remote_name="origin"
main_branch="master"
gh_pages_branch="gh-pages"
cd "$GITHUB_WORKSPACE"
git config user.name "$GITHUB_ACTOR"
git config user.email "${GITHUB_ACTOR}@bots.github.com"
# git rebase "${remote_name}/${main_branch}"
git checkout "$gh_pages_branch"
mkdir tmp
mkdir tmp/resources
mkdir tmp/v2
mkdir tmp/updatelog
touch raw_data1.json deaths_recoveries1.json
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/
cp -r districts_daily/ ./tmp/
git checkout "$main_branch"
cp README.md tmp/
node src/sheets-to-csv.js
node src/sheet-to-json_generic.js
# node src/raw_data-to-state_district_wise_data.js
node src/generate_activity_log.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/sanity_check.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.
git status | grep 'new file\|modified'
if [ $? -eq 0 ]
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"