-
Notifications
You must be signed in to change notification settings - Fork 278
/
update.sh
executable file
·35 lines (25 loc) · 1.03 KB
/
update.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
#!/bin/bash
set -e
set -o pipefail
BRANCH=itsp-update-$(date "+%Y-%m-%d")
REPO=$(git remote -v | grep "^origin.\+\(push\)" | awk '{print $2}' | perl -e 's/^(https:\/\/|git@)github.com[:\/](.+?)(\.git)?$/$2/' -pi)
git fetch origin
git checkout origin/master
git branch -D "$BRANCH" || true
git checkout -b "$BRANCH"
set +e
# https://github.com/curl/curl/issues/3206#issuecomment-437625637
JSON=$(curl --insecure --http1.1 https://ea.gsa.gov/api/v0/itstandards)
if [ $? -ne 0 ]; then
echo "ERROR: Unable to reach ea.gsa.gov. Are you connected to the GSA network?"
exit 1
fi
set -e
echo "$JSON" | python3 json_to_csv.py > it-standards.csv
echo "it-standards.csv updated."
read -r -p "Next, you will be shown a diff of what's changed in CSV. Once you quit the reader, the changes will be committed. Press enter to continue.> "
# https://stackoverflow.com/a/37181160/358804
git diff --word-diff-regex="[^[:space:],]+"
git commit -am "update IT Standards List"
git push -u origin "$BRANCH"
open "https://github.com/$REPO/compare/$BRANCH?expand=1"