forked from covid19india/api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpushthejson
46 lines (35 loc) · 1.06 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
#!/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"
target_branch="master"
cd "$GITHUB_WORKSPACE"
git config user.name "$GITHUB_ACTOR"
git config user.email "${GITHUB_ACTOR}@bots.github.com"
git checkout "$target_branch"
git rebase "${remote_name}/${main_branch}"
npm install drive-db
npm install node-fetch
npm install moment
npm install moment-timezone
cp ./data.json ./data_prev.json
node sheet-to-json_generic.js
node raw_data-to-state_district_wise_data.js
node generate_activity_log.js ${BOT_TOKEN}
node states_daily_to_csv.js
rm ./data_prev.json
git add updatelog/ *.json
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" "$target_branch"
else
set -e
echo "No changes since last run"
fi
echo "finish"