roc/ci/safe-earthly.sh

24 lines
540 B
Bash
Raw Normal View History

2021-05-25 18:00:49 +03:00
#!/usr/bin/env bash
2021-05-25 18:26:07 +03:00
LOG_FILE="earthly_log.txt"
touch $LOG_FILE
2021-05-25 18:00:49 +03:00
2021-06-09 20:31:04 +03:00
# first arg + everything after
ARGS=${@:1}
2021-06-09 20:40:27 +03:00
FULL_CMD="earthly --config ci/earthly-conf.yml $ARGS"
echo $FULL_CMD
script -efq $LOG_FILE -c "$FULL_CMD"
EXIT_CODE=$?
2021-05-25 18:00:49 +03:00
2021-05-25 18:26:07 +03:00
if grep -q "failed to mount" "$LOG_FILE"; then
2021-05-25 18:00:49 +03:00
echo ""
echo ""
echo "------<<<<<<!!!!!!>>>>>>------"
echo "DETECTED FAILURE TO MOUNT ERROR: running without cache"
echo "------<<<<<<!!!!!!>>>>>>------"
echo ""
echo ""
earthly --config ci/earthly-conf.yml --no-cache $ARGS
2021-05-25 18:00:49 +03:00
else
exit $EXIT_CODE
2021-05-25 18:00:49 +03:00
fi