2019-11-11 22:18:16 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-11-28 17:27:43 +00:00
|
|
|
# Check for AWS Credentials
|
|
|
|
[ -n "$AWS_SECRET_ACCESS_KEY" ] || {
|
2022-11-28 18:16:43 +00:00
|
|
|
echo "AWS_SECRET_ACCESS_KEY is not set"
|
2022-11-28 17:27:43 +00:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
[ -n "$AWS_ACCESS_KEY_ID" ] || {
|
2022-11-28 18:16:43 +00:00
|
|
|
echo "AWS_ACCESS_KEY_ID is not set"
|
2022-11-28 17:27:43 +00:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2019-11-11 22:18:16 +00:00
|
|
|
[ -d "$1" ] || {
|
|
|
|
echo "First argument should be a directory" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
umask 077
|
|
|
|
|
2020-03-25 19:35:07 +00:00
|
|
|
GO=${GO-go}
|
|
|
|
|
2019-11-11 22:18:16 +00:00
|
|
|
TMPDIR=$(mktemp -d)
|
|
|
|
cleanup() {
|
|
|
|
exit_code=$?
|
|
|
|
trap - EXIT INT
|
|
|
|
rm -rf ${TMPDIR}
|
|
|
|
exit ${exit_code}
|
|
|
|
}
|
|
|
|
trap cleanup EXIT INT
|
|
|
|
|
2020-03-25 19:35:07 +00:00
|
|
|
LOG_TGZ=k3s-log-$(date +%s)-$("${GO}" env GOARCH)-$(git rev-parse --short HEAD)-$(basename $1).tgz
|
2019-11-11 22:18:16 +00:00
|
|
|
|
|
|
|
tar -cz -f ${TMPDIR}/${LOG_TGZ} -C $(dirname $1) $(basename $1)
|
2022-11-28 17:27:43 +00:00
|
|
|
aws s3 cp ${TMPDIR}/${LOG_TGZ} s3://k3s-ci-logs || exit 1
|
2019-11-11 22:18:16 +00:00
|
|
|
echo "Logs uploaded" >&2
|
2022-11-28 17:27:43 +00:00
|
|
|
echo "https://k3s-ci-logs.s3.amazonaws.com/${LOG_TGZ}"
|
|
|
|
|