Add continious deployment to stage
This commit is contained in:
1 parent
d9b01a6b2f
commit
5b9825eff8
5 files changed
+122
-3
No files matched your search
@@ -1,4 +1,5 @@
|
||||
.*.sw[po]
|
||||
*.py[co]
|
||||
*.bak
|
||||
upload/
|
||||
build/
|
||||
@@ -12,3 +13,4 @@ coverage/
|
||||
npm-debug.log
|
||||
test-dist/
|
||||
coverage-dist/
|
||||
venv/
|
||||
+14
-3
@@ -1,24 +1,35 @@
|
||||
sudo: false
|
||||
dist: trusty
|
||||
language: node_js
|
||||
node_js:
|
||||
- '6'
|
||||
env:
|
||||
matrix:
|
||||
- SAUCE=true
|
||||
global:
|
||||
secure: fj2CF7TO1mpoM/Ft1wSIpGapoA+hqXLpUVe2iZXsGgeKVONAyh5k+s1cd9h/xGlnOmW5HyyN1M8YiTTWEjdT1yLwLYiL+cUdcW+BZBZWLN84lbjQimmDvB84ukMAdBeGz6XgSdmMYLFjZoh89qC3D0lukLZV0RdJOR8SmntwuRg=
|
||||
addons:
|
||||
chrome: stable
|
||||
firefox: latest
|
||||
apt:
|
||||
packages:
|
||||
- python3-pip
|
||||
script:
|
||||
- npm test
|
||||
- npm run cover
|
||||
- npm run browser-test
|
||||
- npm run lint
|
||||
- ./ci/coveralls.sh
|
||||
after_sucess:
|
||||
- ci/coveralls.sh
|
||||
git:
|
||||
depth: 1
|
||||
submodules: false
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
before_deploy:
|
||||
- ci/build.sh
|
||||
deploy:
|
||||
skip_cleanup: true
|
||||
provider: script
|
||||
script: ci/travis_deploy.sh
|
||||
on:
|
||||
branch: master
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
CLOSURE_COMPILER_URL="https://dl.google.com/closure-compiler/compiler-latest.zip"
|
||||
|
||||
install_closure() {
|
||||
wget $CLOSURE_COMPILER_URL -O /tmp/closure.zip
|
||||
mkdir /tmp/closure/
|
||||
unzip /tmp/closure.zip -d /tmp/closure/
|
||||
CLOSURE_JAR=$(ls /tmp/closure/closure-compiler-*.jar)
|
||||
export CLOSURE_PATH=$CLOSURE_JAR
|
||||
}
|
||||
|
||||
build_package() {
|
||||
PRODUCTION=1 npm run webpack
|
||||
}
|
||||
|
||||
|
||||
install_closure
|
||||
build_package
|
||||
|
||||
ls dist/
|
||||
Executable
+78
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
import os
|
||||
import boto3
|
||||
import mimetypes
|
||||
import argparse
|
||||
|
||||
|
||||
UPLOAD_ORDER = [
|
||||
(re.compile(r'.*\.html$'), -1)
|
||||
]
|
||||
|
||||
CACHE_RULES = [
|
||||
(re.compile(r'.*\.html$'), "public, max-age=120"),
|
||||
(re.compile(r'.*\.(css|js)$'), "public, s-maxage=31536000, max-age=86400")
|
||||
]
|
||||
|
||||
DEFAULT_PRIORITY = 0
|
||||
|
||||
|
||||
def deployment_files(deploy_dir):
|
||||
for root, dirs, files in os.walk(deploy_dir):
|
||||
for filename in files:
|
||||
file_path = os.path.join(root, filename)
|
||||
yield os.path.relpath(file_path, start=deploy_dir)
|
||||
|
||||
|
||||
def sorted_files(deploy_dir):
|
||||
"Returns files in right order"
|
||||
files = list(deployment_files(deploy_dir))
|
||||
match_rules = []
|
||||
|
||||
def sort_key(filename):
|
||||
for pattern, priority in UPLOAD_ORDER:
|
||||
if pattern.match(filename):
|
||||
return (priority, filename)
|
||||
|
||||
return (DEFAULT_PRIORITY, filename)
|
||||
|
||||
files.sort(key=sort_key, reverse=True)
|
||||
return files
|
||||
|
||||
|
||||
def file_options(file_name):
|
||||
mimetype, _ = mimetypes.guess_type(file_name)
|
||||
if mimetype is None:
|
||||
mimetype = 'application/octet-stream'
|
||||
|
||||
extra_config = {
|
||||
'ContentType': mimetype
|
||||
}
|
||||
|
||||
for pattern, value in CACHE_RULES:
|
||||
if pattern.match(file_name):
|
||||
extra_config['CacheControl'] = value
|
||||
break
|
||||
|
||||
return extra_config
|
||||
|
||||
|
||||
def update_site(deploy_dir, bucket_name):
|
||||
s3 = boto3.resource('s3')
|
||||
bucket = s3.Bucket(bucket_name)
|
||||
|
||||
for file_name in sorted_files(deploy_dir):
|
||||
file_path = os.path.join(deploy_dir, file_name)
|
||||
extra = file_options(file_name)
|
||||
print("Uploading: {}".format(file_name))
|
||||
bucket.upload_file(file_path, file_name, extra)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Deploy site to s3')
|
||||
parser.add_argument("deploy_dir")
|
||||
parser.add_argument("s3_bucket")
|
||||
args = parser.parse_args()
|
||||
update_site(args.deploy_dir, args.s3_bucket)
|
||||
print("Done")
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ -n "$CI" ]; then
|
||||
pip3 install --user boto3
|
||||
fi
|
||||
./ci/deploy.py ./dist/ beta.bios-pw.org
|
||||
Reference in new issue
Block a user