Skip to content

Commit

Permalink
deploy to CN regions (mapbox#2915)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmully authored and lucaswoj committed Aug 2, 2016
1 parent 6b24033 commit e601b81
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 2 deletions.
71 changes: 71 additions & 0 deletions cloudformation/travis-cn.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "mapbox-gl-js build user",
"Resources": {
"BuildUser": {
"Type": "AWS::IAM::User",
"Properties": {
"Policies": [
{
"PolicyName": "list",
"PolicyDocument": {
"Statement": [
{
"Action": [
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": [
"arn:aws-cn:s3:::mapbox-gl-js-cn-north-1"
]
}
]
}
},
{
"PolicyName": "build",
"PolicyDocument": {
"Statement": [
{
"Action": [
"s3:GetObject",
"s3:GetObjectAcl",
"s3:PutObject",
"s3:PutObjectAcl"
],
"Effect": "Allow",
"Resource": [
"arn:aws-cn:s3:::mapbox-gl-js-cn-north-1/*"
]
}
]
}
}
]
}
},
"BuildUserKey": {
"Type": "AWS::IAM::AccessKey",
"Properties": {
"UserName": {
"Ref": "BuildUser"
}
}
}
},
"Outputs": {
"AwsAccessKeyId": {
"Value": {
"Ref": "BuildUserKey"
}
},
"AwsSecretAccessKey": {
"Value": {
"Fn::GetAtt": [
"BuildUserKey",
"SecretAccessKey"
]
}
}
}
}
22 changes: 20 additions & 2 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@ if [ -z $TAG ]; then
fi

function upload {
aws s3 cp --acl public-read --content-type $2 dist/$1 s3://mapbox-gl-js/$TAG/$1
echo "upload: dist/$1 to s3://mapbox-gl-js/$TAG/$1"
aws s3 cp --acl public-read --content-type $2 dist/$1 s3://mapbox-gl-js/$TAG/$1
echo "upload: dist/$1 to s3://mapbox-gl-js/$TAG/$1"
}

cnregions="
cn-north-1
"

function cn_upload {
for region in cnregions; do
aws s3 cp --region $region --acl public-read --content-type $2 dist/$1 s3://mapbox-gl-js-$region/$TAG/$1
echo "upload: dist/$1 to s3://mapbox-gl-js-$region/$TAG/$1"
done
}

npm run build-dev
Expand All @@ -21,3 +32,10 @@ upload mapbox-gl.js application/javascript
upload mapbox-gl.js.map application/octet-stream
upload mapbox-gl-dev.js application/javascript
upload mapbox-gl.css text/css

export AWS_ACCESS_KEY_ID=$AWSCN_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY=$AWSCN_SECRET_ACCESS_KEY
cn_upload mapbox-gl.js application/javascript
cn_upload mapbox-gl.js.map application/octet-stream
cn_upload mapbox-gl-dev.js application/javascript
cn_upload mapbox-gl.css text/css

0 comments on commit e601b81

Please sign in to comment.