-
Notifications
You must be signed in to change notification settings - Fork 521
/
Copy pathupdate_gh_pages.sh
executable file
·36 lines (30 loc) · 1.13 KB
/
update_gh_pages.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
#!/bin/bash
set -euo pipefail
# Current commit hash on the source branch.
SRC_BRANCH=main
# Switch to gh-pages branch.
git checkout gh-pages
# Get the YAML and the scripts we need to generate CSV and JSON
# from the source branch.
git fetch origin $SRC_BRANCH
HASH=$(git rev-parse FETCH_HEAD)
echo "Getting latest files from $SRC_BRANCH @ $HASH."
git checkout FETCH_HEAD "*.yaml" scripts/alternate_bulk_formats.py scripts/utils.py
# Generate CSV and JSON.
(cd scripts/; python3 alternate_bulk_formats.py;)
# Commit the YAML, CSV, and JSON.
# (Don't commit the other scripts files we checked out from
# the source branch, which git has unhelpfully put in the
# index.)
export GIT_AUTHOR_NAME="the unitedstates project (CircleCI)"
export GIT_AUTHOR_EMAIL=circleci@theunitedstates.io
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
export GIT_COMMITTER_EMAIL="GIT_AUTHOR_EMAIL"
(
git add *.yaml *.csv *.json \
&& git commit -m "update to $SRC_BRANCH @ $HASH by CircleCI" \
*.yaml *.csv *.json \
&& git push
) || /bin/true # if there's nothing to commit, don't exit with error status
# Switch back to the original branch.
git checkout -f $SRC_BRANCH