2018-08-13 17:59:56 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-11-05 14:33:48 +00:00
|
|
|
# Replace / with _ to create a valid tag
|
2019-11-11 09:36:38 +00:00
|
|
|
TAG=$(echo "${BRANCH_NAME}" | sed -e "s/\//_/g")
|
2019-11-05 14:33:48 +00:00
|
|
|
echo "Running for ${TAG}"
|
2018-08-13 17:59:56 +00:00
|
|
|
|
2018-12-02 21:49:30 +00:00
|
|
|
# Add commit and commit_message to docker container
|
2019-11-05 14:33:48 +00:00
|
|
|
echo "${GITHUB_SHA}" > freqtrade_commit
|
2018-12-02 21:49:30 +00:00
|
|
|
|
2019-11-11 18:42:05 +00:00
|
|
|
if [ "${GITHUB_EVENT_NAME}" = "schedule" ]; then
|
2019-11-05 14:33:48 +00:00
|
|
|
echo "event ${GITHUB_EVENT_NAME}: full rebuild - skipping cache"
|
2018-10-21 12:00:01 +00:00
|
|
|
docker build -t freqtrade:${TAG} .
|
|
|
|
else
|
2019-11-05 14:33:48 +00:00
|
|
|
echo "event ${GITHUB_EVENT_NAME}: building with cache"
|
2018-10-21 12:00:01 +00:00
|
|
|
# Pull last build to avoid rebuilding the whole image
|
2019-01-08 19:09:32 +00:00
|
|
|
docker pull ${IMAGE_NAME}:${TAG}
|
2018-10-21 12:00:01 +00:00
|
|
|
docker build --cache-from ${IMAGE_NAME}:${TAG} -t freqtrade:${TAG} .
|
|
|
|
fi
|
|
|
|
|
2018-08-13 17:59:56 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "failed building image"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Run backtest
|
2019-11-14 05:45:14 +00:00
|
|
|
docker run --rm -v $(pwd)/config.json.example:/freqtrade/config.json:ro -v $(pwd)/tests:/tests freqtrade:${TAG} backtesting --datadir /tests/testdata --strategy DefaultStrategy
|
2018-08-13 17:59:56 +00:00
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "failed running backtest"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Tag image for upload
|
|
|
|
docker tag freqtrade:$TAG ${IMAGE_NAME}:$TAG
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "failed tagging image"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Tag as latest for develop builds
|
2019-11-05 14:33:48 +00:00
|
|
|
if [ "${GITHUB_REF}" = "develop" ]; then
|
2018-08-13 17:59:56 +00:00
|
|
|
docker tag freqtrade:$TAG ${IMAGE_NAME}:latest
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Login
|
2019-11-05 14:33:48 +00:00
|
|
|
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
|
2018-08-13 17:59:56 +00:00
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "failed login"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Show all available images
|
|
|
|
docker images
|
|
|
|
|
|
|
|
docker push ${IMAGE_NAME}
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "failed pushing repo"
|
|
|
|
return 1
|
|
|
|
fi
|