1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-07-01 06:02:10 +02:00

Merge pull request #26 from oceanprotocol/feature/deployment

setup deployment
This commit is contained in:
Matthias Kretschmann 2018-11-16 14:35:24 +01:00 committed by GitHub
commit 4bbdd2592e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 81 additions and 1 deletions

View File

@ -7,6 +7,11 @@ script:
- npm test
- 'if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]; then npm run build; fi'
after_success:
- pip install --user awscli
- export PATH=$PATH:$HOME/.local/bin
- npm run deploy
notifications:
email: false

View File

@ -30,6 +30,7 @@
- [Linting & formatting](#linting--formatting)
- [Editor setup: VS Code](#editor-setup-vs-code)
- [GitHub GraphQL API](#github-graphql-api)
- [Deployment](#deployment)
- [Authors](#authors)
- [License](#license)
@ -271,6 +272,27 @@ query {
}
```
## Deployment
Automatic deployments are triggered upon successful tests & builds on Travis:
- push to `master` initiates a live deployment
-> [docs.oceanprotocol.com](https://docs.oceanprotocol.com)
- any Pull Request, and subsequent pushes to it, initiates a beta deployment
-> [beta.docs.oceanprotocol.com](https://beta.docs.oceanprotocol.com)
The deploy command simply calls the [`scripts/deploy.sh`](scripts/deploy.sh) script, syncing the contents of the `public/` folder to S3:
```bash
npm run deploy
```
Requires authorization against AWS with [one of the various ways](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html), on Travis this is done with those environment variables:
- `AWS_ACCESS_KEY_ID`
- `AWS_SECRET_ACCESS_KEY`
- `AWS_DEFAULT_REGION`
## Authors
- Troy McConaghy ([@ttmc](https://github.com/ttmc)) - [Ocean Protocol](https://oceanprotocol.com)

View File

@ -18,7 +18,8 @@
"lint:md": "markdownlint './**/*.{md,markdown}' --ignore './{node_modules,external,public}/**/*'",
"lint:yml": "prettier '**/*.{yml,yaml}' --list-different",
"lint": "run-p --continue-on-error lint:js lint:css lint:md lint:yml",
"test": "npm run lint"
"test": "npm run lint",
"deploy": "./scripts/deploy.sh"
},
"dependencies": {
"@oceanprotocol/art": "^1.0.2",

52
scripts/deploy.sh Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env bash
#
# required environment variables:
# AWS_ACCESS_KEY_ID
# AWS_SECRET_ACCESS_KEY
# AWS_DEFAULT_REGION
AWS_S3_BUCKET="docs.oceanprotocol.com"
AWS_S3_BUCKET_BETA="beta.docs.oceanprotocol.com"
SITEMAP_URL="https%3A%2F%2Fdocs.oceanprotocol.com%2Fsitemap.xml"
#
set -e;
function s3sync {
aws s3 sync ./public s3://"$1" --exclude "*.html" --exclude "*.xml" --cache-control max-age=31536000,public,immutable --delete --acl public-read --quiet
aws s3 sync ./public s3://"$1" --exclude "*" --include "*.html" --include "*.xml" --cache-control max-age=0,no-cache,no-store,must-revalidate --delete --acl public-read --quiet
}
##
## check for pull request against master
##
if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
s3sync $AWS_S3_BUCKET_BETA
##
## check for master push which is no pull request
##
elif [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] || [ "$TRAVIS" != true ]; then
s3sync $AWS_S3_BUCKET
# ping search engines
# returns: HTTP_STATUSCODE URL
# curl -sL -w "%{http_code} %{url_effective}\\n" \
# "http://www.google.com/webmasters/tools/ping?sitemap=$SITEMAP_URL" -o /dev/null \
# "http://www.bing.com/webmaster/ping.aspx?siteMap=$SITEMAP_URL" -o /dev/null
echo "---------------------------------------------"
echo " ✓ done deployment "
echo "---------------------------------------------"
exit;
else
echo "---------------------------------------------"
echo " nothing to deploy "
echo "---------------------------------------------"
fi