Commit 45b3f7f7 authored by Mislav Marohnić's avatar Mislav Marohnić
Browse files

🔥 Travis CI

parent ebdcf0c2
Loading
Loading
Loading
Loading

.travis.yml

deleted100644 → 0
+0 −12
Original line number Diff line number Diff line
sudo: false
install: git clone --depth 1 https://github.com/sstephenson/bats.git
script: PATH="./bats/bin:$PATH" script/travis
language: c
notifications:
  email:
    on_success: never
env:
  global:
    - AMAZON_S3_BUCKET=ruby-build-mirror
    - AMAZON_ACCESS_KEY_ID=AKIAJKAUQVHU6X4CODDQ
    - secure: LTSvDP2o72nbECDwWsfwnsiETF4VpqrYN3y/ve68AZIMzfNWDB5vhqzMLU1ltFnSNxd71gTCGX2OEcsxdrfnG+Msu52v8FtJ7lz/b9xn83gGYrGnmEMzARtd1fnuzlWQh/1eNL9jrNl8FDhgjoTqKl2gF6fZBsQxcHRnvRSXcqE=

script/s3-put

deleted100755 → 0
+0 −63
Original line number Diff line number Diff line
#!/usr/bin/env bash
# Usage: s3-put <FILE> <S3_BUCKET> [<CONTENT_TYPE>]
#
# Uploads a file to the Amazon S3 service.
#
# Depends on AWS credentials being set via env:
# - AMAZON_ACCESS_KEY_ID
# - AMAZON_SECRET_ACCESS_KEY
#
# Outputs the URL of the newly uploaded file.
set -e

authorization() {
  local signature="$(string_to_sign | hmac_sha1 | base64)"
  echo "AWS ${AMAZON_ACCESS_KEY_ID?}:${signature}"
}

hmac_sha1() {
  openssl dgst -binary -sha1 -hmac "${AMAZON_SECRET_ACCESS_KEY?}"
}

base64() {
  openssl enc -base64
}

bin_md5() {
  openssl dgst -binary -md5
}

string_to_sign() {
  echo "$http_method"
  echo "$content_md5"
  echo "$content_type"
  echo "$date"
  echo "x-amz-acl:$acl"
  printf "/$bucket/$remote_path"
}

date_string() {
  LC_TIME=C date "+%a, %d %h %Y %T %z"
}

file="$1"
bucket="$2"
content_type="$3"

http_method=PUT
acl="public-read"
remote_path="${file##*/}"
content_md5="$(bin_md5 < "$file" | base64)"
date="$(date_string)"

url="https://$bucket.s3.amazonaws.com/$remote_path"

curl -qsSf -T "$file" \
  -H "Authorization: $(authorization)" \
  -H "x-amz-acl: $acl" \
  -H "Date: $date" \
  -H "Content-MD5: $content_md5" \
  -H "Content-Type: $content_type" \
  "$url"

echo "$url"

script/travis

deleted100755 → 0
+0 −7
Original line number Diff line number Diff line
#!/usr/bin/env bash
set -e
set -x

if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]; then
  ./script/mirror update "$TRAVIS_COMMIT_RANGE"
fi