ci-scripts/s3/s3upload.sh
2023-08-22 20:36:08 +02:00

25 lines
No EOL
699 B
Bash

#!/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}