mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
Merge pull request #528 from oceanprotocol/feature/deployment
deployment & CI switch
This commit is contained in:
commit
43156ca396
3
.github/CONTRIBUTING.md
vendored
3
.github/CONTRIBUTING.md
vendored
@ -1,3 +0,0 @@
|
|||||||
# Contributing
|
|
||||||
|
|
||||||
See the page titled "[Ways to Contribute](https://docs.oceanprotocol.com/concepts/contributing/)" in the Ocean Protocol documentation.
|
|
34
.github/workflows/ci.yml
vendored
Normal file
34
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
name: 'CI'
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '**'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: '14'
|
||||||
|
|
||||||
|
- name: Cache node modules
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: ${{ runner.os }}-node-
|
||||||
|
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
- run: npm run build
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
31
.travis.yml
31
.travis.yml
@ -1,31 +0,0 @@
|
|||||||
dist: xenial
|
|
||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- '12'
|
|
||||||
|
|
||||||
# Deploying uses awscli and it uses Python.
|
|
||||||
# Xenial on Travis comes with Python 2 & 3 installed but 2 is default.
|
|
||||||
# Ensure pip3 is installed and upgraded.
|
|
||||||
before_install:
|
|
||||||
- sudo apt-get -qq update
|
|
||||||
- sudo apt-get install python3-pip
|
|
||||||
- sudo -H pip3 install --upgrade pip
|
|
||||||
- sudo -H pip3 install -U setuptools
|
|
||||||
|
|
||||||
script:
|
|
||||||
# will run `npm ci` automatically here
|
|
||||||
- npm test
|
|
||||||
- 'if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]; then npm run build; fi'
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- pip3 install --user awscli
|
|
||||||
- export PATH=$PATH:$HOME/.local/bin
|
|
||||||
- npm run deploy
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
email: false
|
|
||||||
|
|
||||||
cache:
|
|
||||||
npm: true
|
|
||||||
directories:
|
|
||||||
- public
|
|
36
README.md
36
README.md
@ -4,11 +4,10 @@
|
|||||||
|
|
||||||
> 🐬 Ocean Protocol documentation. https://docs.oceanprotocol.com
|
> 🐬 Ocean Protocol documentation. https://docs.oceanprotocol.com
|
||||||
|
|
||||||
[](https://travis-ci.com/oceanprotocol/docs)
|
[](https://github.com/oceanprotocol/docs/actions)
|
||||||
[](https://codeclimate.com/github/oceanprotocol/docs/maintainability)
|
[](https://codeclimate.com/github/oceanprotocol/docs/maintainability)
|
||||||
[](https://github.com/oceanprotocol/eslint-config-oceanprotocol)
|
[](https://github.com/oceanprotocol/eslint-config-oceanprotocol)
|
||||||
[](https://github.com/bigchaindb/stylelint-config-bigchaindb)
|
[](https://github.com/bigchaindb/stylelint-config-bigchaindb)
|
||||||
[](https://greenkeeper.io/)
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -22,7 +21,8 @@
|
|||||||
- [Development](#development)
|
- [Development](#development)
|
||||||
- [Linting & Formatting](#linting--formatting)
|
- [Linting & Formatting](#linting--formatting)
|
||||||
- [Editor Setup: VS Code](#editor-setup-vs-code)
|
- [Editor Setup: VS Code](#editor-setup-vs-code)
|
||||||
- [Deployment](#deployment)
|
- [⬆️ Deployment](#️-deployment)
|
||||||
|
- [Manual Deployment](#manual-deployment)
|
||||||
- [License](#license)
|
- [License](#license)
|
||||||
|
|
||||||
## Content
|
## Content
|
||||||
@ -41,7 +41,7 @@ The site is a React app built with [Gatsby](https://www.gatsbyjs.org), pulling i
|
|||||||
To start, clone this repo and set your `GITHUB_TOKEN` (see [GitHub GraphQL API](docs/github.md#GitHub-GraphQL-API)):
|
To start, clone this repo and set your `GITHUB_TOKEN` (see [GitHub GraphQL API](docs/github.md#GitHub-GraphQL-API)):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone --recurse-submodules git@github.com:oceanprotocol/docs.git
|
git clone git@github.com:oceanprotocol/docs.git
|
||||||
cd docs/
|
cd docs/
|
||||||
|
|
||||||
# add GITHUB_TOKEN
|
# add GITHUB_TOKEN
|
||||||
@ -93,27 +93,27 @@ If you use VS Code as your editor, you can install those extensions to get linti
|
|||||||
- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
|
- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
|
||||||
- [markdownlint](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint)
|
- [markdownlint](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint)
|
||||||
|
|
||||||
## Deployment
|
## ⬆️ Deployment
|
||||||
|
|
||||||
Automatic deployments are triggered upon successful tests & builds on Travis:
|
Every branch or Pull Request is automatically deployed by [Vercel](https://vercel.com) with their GitHub integration. A link to a deployment will appear under each Pull Request.
|
||||||
|
|
||||||
- push to `main` initiates a live deployment
|
The latest deployment of the `main` branch is automatically aliased to `oceanprotocol.com`.
|
||||||
→ [docs.oceanprotocol.com](https://docs.oceanprotocol.com)
|
|
||||||
- any Pull Request, and subsequent pushes to it, initiates a beta deployment
|
|
||||||
→ [betadocs.oceanprotocol.com](https://betadocs.oceanprotocol.com)
|
|
||||||
|
|
||||||
The deploy command simply calls the [`scripts/deploy.sh`](scripts/deploy.sh) script, syncing the contents of the `public/` folder to S3:
|
### Manual Deployment
|
||||||
|
|
||||||
|
If needed, app can be deployed manually. Make sure to switch to Ocean Protocol org before deploying:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run deploy
|
# first run
|
||||||
|
vercel login
|
||||||
|
vercel switch
|
||||||
|
|
||||||
|
# deploy
|
||||||
|
vercel
|
||||||
|
# switch alias to new deployment
|
||||||
|
vercel alias
|
||||||
```
|
```
|
||||||
|
|
||||||
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`
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
"lint:md": "markdownlint './**/*.{md,markdown}' --ignore './{node_modules,external,public,.cache}/**/*'",
|
"lint:md": "markdownlint './**/*.{md,markdown}' --ignore './{node_modules,external,public,.cache}/**/*'",
|
||||||
"lint:yml": "prettier '**/*.{yml,yaml}' --list-different",
|
"lint:yml": "prettier '**/*.{yml,yaml}' --list-different",
|
||||||
"lint": "run-p --continue-on-error lint:js lint:md lint:yml",
|
"lint": "run-p --continue-on-error lint:js lint:md lint:yml",
|
||||||
"test": "npm run lint",
|
"test": "npm run lint"
|
||||||
"deploy": "./scripts/deploy.sh"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@oceanprotocol/art": "^3.0.0",
|
"@oceanprotocol/art": "^3.0.0",
|
||||||
|
@ -1,76 +0,0 @@
|
|||||||
#!/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="betadocs.oceanprotocol.com"
|
|
||||||
SITEMAP_URL="https%3A%2F%2Fdocs.oceanprotocol.com%2Fsitemap.xml"
|
|
||||||
|
|
||||||
#
|
|
||||||
set -e;
|
|
||||||
|
|
||||||
function s3sync {
|
|
||||||
aws s3 sync ./public s3://"$1" \
|
|
||||||
--include "*" \
|
|
||||||
--exclude "*.html" \
|
|
||||||
--exclude "sw.js" \
|
|
||||||
--exclude "*page-data.json" \
|
|
||||||
--exclude "chunk-map.json" \
|
|
||||||
--exclude "sitemap.xml" \
|
|
||||||
--exclude ".iconstats.json" \
|
|
||||||
--exclude "humans.txt" \
|
|
||||||
--exclude "robots.txt" \
|
|
||||||
--cache-control public,max-age=31536000,immutable \
|
|
||||||
--delete \
|
|
||||||
--acl public-read
|
|
||||||
|
|
||||||
aws s3 sync ./public s3://"$1" \
|
|
||||||
--exclude "*" \
|
|
||||||
--include "*.html" \
|
|
||||||
--include "sw.js" \
|
|
||||||
--include "*page-data.json" \
|
|
||||||
--include "chunk-map.json" \
|
|
||||||
--include "sitemap.xml" \
|
|
||||||
--include ".iconstats.json" \
|
|
||||||
--include "humans.txt" \
|
|
||||||
--include "robots.txt" \
|
|
||||||
--cache-control public,max-age=0,must-revalidate \
|
|
||||||
--delete \
|
|
||||||
--acl public-read
|
|
||||||
}
|
|
||||||
|
|
||||||
##
|
|
||||||
## check for pull request against main
|
|
||||||
##
|
|
||||||
if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" == "main" ]; then
|
|
||||||
|
|
||||||
s3sync $AWS_S3_BUCKET_BETA
|
|
||||||
|
|
||||||
##
|
|
||||||
## check for main push which is no pull request
|
|
||||||
##
|
|
||||||
elif [ "$TRAVIS_BRANCH" == "main" ] && [ "$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