Created
April 26, 2017 07:34
-
-
Save TomDunn/d964c509ea7a5e568dbd0e36603876e2 to your computer and use it in GitHub Desktop.
Upload zip to S3 from Bitbucket pipelines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BUCKET="!!!!!!!!YOUR_AMAZON_S3_BUCKET_NAME_HERE!!!!!!!!!!" | |
CONTENT_TYPE="application/zip" | |
DATE=`date -R` | |
IN_FILE="revision.zip" | |
KEY="demo/revision.zip" | |
RESOURCE="/${BUCKET}/${KEY}" | |
HMAC="PUT\n\n${CONTENT_TYPE}\n${DATE}\n${RESOURCE}" | |
zip -r --exclude=*.git* "$IN_FILE" . | |
SIGNATURE=`echo -en ${HMAC} | openssl sha1 -hmac ${API_SECRET} -binary | base64` | |
curl -X PUT -T "${IN_FILE}" \ | |
-H "Host: ${BUCKET}.s3.amazonaws.com" \ | |
-H "Date: ${DATE}" \ | |
-H "Content-Type: ${CONTENT_TYPE}" \ | |
-H "Authorization: AWS ${API_KEY}:${SIGNATURE}" \ | |
https://${BUCKET}.s3.amazonaws.com/${KEY} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipelines: | |
default: | |
- step: | |
script: # Modify the commands below to build your repository. | |
- apt-get update | |
- apt-get install zip openssl curl | |
- bash ./.upload.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment