ci-scripts/s3/s3upload.sh

25 lines
699 B
Bash
Raw Normal View History

2023-08-22 18:36:08 +00:00
#!/bin/bash
# S3 upload script for CI-Builds
# ./s3upload.sh bucket file.zip | Warning if file is in folder folder gets created on path!
s3_bucket=$1
s3_file=$2
# Needed environment vars:
# s3_host
# s3_key
# s3_secret
resource="/${s3_bucket}/${s3_file}"
content_type="application/octet-stream"
date=`date -R`
_signature="PUT\n\n${content_type}\n${date}\n${resource}"
signature=`echo -en ${_signature} | openssl sha1 -hmac ${s3_secret} -binary | base64`
curl -X PUT -T "${s3_file}" \
-H "Host: ${s3_host}" \
-H "Date: ${date}" \
-H "Content-Type: ${content_type}" \
-H "Authorization: AWS ${s3_key}:${signature}" \
https://${s3_host}${resource}