mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
Merge pull request #26 from oceanprotocol/feature/deployment
setup deployment
This commit is contained in:
commit
4bbdd2592e
@ -7,6 +7,11 @@ script:
|
|||||||
- npm test
|
- npm test
|
||||||
- 'if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]; then npm run build; fi'
|
- '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:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
|
||||||
|
22
README.md
22
README.md
@ -30,6 +30,7 @@
|
|||||||
- [Linting & formatting](#linting--formatting)
|
- [Linting & formatting](#linting--formatting)
|
||||||
- [Editor setup: VS Code](#editor-setup-vs-code)
|
- [Editor setup: VS Code](#editor-setup-vs-code)
|
||||||
- [GitHub GraphQL API](#github-graphql-api)
|
- [GitHub GraphQL API](#github-graphql-api)
|
||||||
|
- [Deployment](#deployment)
|
||||||
- [Authors](#authors)
|
- [Authors](#authors)
|
||||||
- [License](#license)
|
- [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
|
## Authors
|
||||||
|
|
||||||
- Troy McConaghy ([@ttmc](https://github.com/ttmc)) - [Ocean Protocol](https://oceanprotocol.com)
|
- Troy McConaghy ([@ttmc](https://github.com/ttmc)) - [Ocean Protocol](https://oceanprotocol.com)
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
"lint:md": "markdownlint './**/*.{md,markdown}' --ignore './{node_modules,external,public}/**/*'",
|
"lint:md": "markdownlint './**/*.{md,markdown}' --ignore './{node_modules,external,public}/**/*'",
|
||||||
"lint:yml": "prettier '**/*.{yml,yaml}' --list-different",
|
"lint:yml": "prettier '**/*.{yml,yaml}' --list-different",
|
||||||
"lint": "run-p --continue-on-error lint:js lint:css lint:md lint:yml",
|
"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": {
|
"dependencies": {
|
||||||
"@oceanprotocol/art": "^1.0.2",
|
"@oceanprotocol/art": "^1.0.2",
|
||||||
|
52
scripts/deploy.sh
Executable file
52
scripts/deploy.sh
Executable 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
|
Loading…
Reference in New Issue
Block a user