-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathupdate-repository-info.sh
executable file
·56 lines (45 loc) · 1.54 KB
/
update-repository-info.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
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# exit on errors
set -e
if [ -z "$CI" ]; then
echo "This script is meant to be run in CI environment. If you really want to run it set env variable CI=true"
exit 1
fi
if [[ ! $(which pyenv) ]] && [[ -n "${CIRCLECI}" ]]; then
echo "pyenv not found. setting up necessary env for pyenv on circle ci";\
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
git config --global user.email "[email protected]"
git config --global user.name "dc-builder"
echo ""
echo "====== `date`: Starting docker repository update ====="
echo ""
pipenv install
pipenv run ./update-docker-repo-info.py
if [[ "$(uname)" == Linux ]]; then
CP_PARENTS="--parents"
else
CP_PARENTS=""
fi
if [[ $(git status --short) ]]; then
echo "found modified/new files to commit"
git status --short
mkdir -p artifacts
# use sed 's:/*$::' to trim trailing slashes from dirs
git status --short | awk '{print $2}' | sed 's:/*$::' | xargs -I {} cp -rf $CP_PARENTS {} artifacts/. || echo "cp failed for some reason. continue..."
if [[ "$CIRCLE_BRANCH" == "master" ]]; then
echo "commit generated data to: $CIRCLE_BRANCH"
git add .
git commit -m "`date`: auto repo info update [skip ci]"
git push
else
echo "Skipping commit as we are NOT on master. Check the generated artifacts of the build to verify."
fi
else
echo "No new files to commit!"
fi
echo ""
echo "====== `date`: Done docker repository update ====="
echo ""