1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00

deployment & CI switch

* deploy to Vercel
* use GitHub Actions for CI
This commit is contained in:
Matthias Kretschmann 2021-01-26 15:57:03 +01:00
parent fc5d6a6513
commit 5ab6d06973
Signed by: m
GPG Key ID: 606EEEF3C479A91F
6 changed files with 51 additions and 130 deletions

View File

@ -1,3 +0,0 @@
# Contributing
See the page titled "[Ways to Contribute](https://docs.oceanprotocol.com/concepts/contributing/)" in the Ocean Protocol documentation.

32
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,32 @@
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

View File

@ -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

View File

@ -4,11 +4,10 @@
> 🐬 Ocean Protocol documentation. https://docs.oceanprotocol.com
[![Build Status](https://travis-ci.com/oceanprotocol/docs.svg?token=3psqw6c8KMDqfdGQ2x6d&branch=master)](https://travis-ci.com/oceanprotocol/docs)
[![Build Status](https://github.com/oceanprotocol/docs/workflows/CI/badge.svg)](https://github.com/oceanprotocol/docs/actions)
[![Maintainability](https://api.codeclimate.com/v1/badges/d39837421591f0bc2550/maintainability)](https://codeclimate.com/github/oceanprotocol/docs/maintainability)
[![js oceanprotocol](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg)](https://github.com/oceanprotocol/eslint-config-oceanprotocol)
[![css bigchaindb](https://img.shields.io/badge/css-bigchaindb-39BA91.svg)](https://github.com/bigchaindb/stylelint-config-bigchaindb)
[![Greenkeeper badge](https://badges.greenkeeper.io/oceanprotocol/docs.svg?token=2757ede2de02f4679c4dfc6597a331a26f2f206fed53bfeb708c64cbe3d5f55f&ts=1541590505792)](https://greenkeeper.io/)
---
@ -22,7 +21,8 @@
- [Development](#development)
- [Linting & Formatting](#linting--formatting)
- [Editor Setup: VS Code](#editor-setup-vs-code)
- [Deployment](#deployment)
- [⬆️ Deployment](#-deployment)
- [Manual Deployment](#manual-deployment)
- [License](#license)
## 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)):
```bash
git clone --recurse-submodules git@github.com:oceanprotocol/docs.git
git clone git@github.com:oceanprotocol/docs.git
cd docs/
# 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)
- [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
→ [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 latest deployment of the `main` branch is automatically aliased to `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
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
```text

View File

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

View File

@ -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