-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathrun_site_checker.sh
47 lines (32 loc) · 956 Bytes
/
run_site_checker.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
#!/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"
file_store_branch="file_store"
git config user.name "$GITHUB_ACTOR"
git config user.email "${GITHUB_ACTOR}@bots.github.com"
git checkout "$file_store_branch"
mkdir ./tmp/
cp -r ./contents ./tmp
git checkout "$main_branch"
mv ./tmp/contents/ .
python3 website_checker.py
cp -r ./contents/ ./tmp/
git checkout "$file_store_branch"
cp -r ./tmp/contents .
rm -rf ./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" "$file_store_branch"
else
set -e
echo "No changes since last run"
fi
git checkout "$main_branch"
echo "finish"