-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9675cf7
Showing
171 changed files
with
16,673 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.git | ||
.github | ||
.env | ||
**/node_modules | ||
**/README.md | ||
**/build | ||
docker-compose.yml | ||
.k8s | ||
.terraform | ||
.npmrc | ||
key.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
NPM_TOKEN= | ||
NEXT_PUBLIC_BASE_PATH=/docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "next/core-web-vitals", | ||
"rules": { | ||
"import/no-anonymous-default-export": "off", | ||
"@next/next/no-img-element": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
set -e # immediately fail the script on any command error | ||
|
||
# wait 5 min for the new pod to be ready. If the pod is not ready there is a problem with the new container | ||
for APP_NAME in "$@" | ||
do | ||
kubectl wait pod --for condition=Ready --timeout=300s \ | ||
$(kubectl get pods -l app=$APP_NAME --sort-by {.metadata.creationTimestamp} -o jsonpath={.items[-1].metadata.name}) | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
set -e # immediately fail the script on any command error | ||
|
||
ENVIRONMENT="$1" | ||
IMAGE="$2" | ||
DIR=$(dirname "$0") | ||
cd $DIR/../../.k8s/$ENVIRONMENT | ||
|
||
kustomize edit set image $IMAGE | ||
kustomize build | kubectl apply -f - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
headers: { | ||
accept: 'text/html', // this avoids graphql endpoint error by returning the playground html | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
set -e # immediately fail the script on any command error | ||
|
||
DIR=$(dirname "$0") | ||
TIMEOUT_MS=10000 | ||
|
||
npx wait-on \ | ||
--verbose \ | ||
--config $DIR/config.js \ | ||
--timeout=$TIMEOUT_MS \ | ||
"$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Production CI/CD | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
env: | ||
BASE_IMAGE: ghcr.io/graphprotocol/graph-docs-production | ||
HEALTH_CHECK_URL: https://thegraph.com/docs | ||
APP_NAME: graph-docs | ||
NEXT_PUBLIC_BASE_PATH: /docs | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: Jannis | ||
password: ${{ secrets.GH_ACCESS_TOKEN_JANNIS }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . # required to respect .dockerignore | ||
cache-from: type=registry,ref=${{ env.BASE_IMAGE }}:latest | ||
cache-to: type=inline | ||
secrets: npmrc=//registry.npmjs.org/:_authToken=${{ secrets.NPM_SECRET_TOKEN }} | ||
tags: | | ||
${{ env.BASE_IMAGE }}:${{ github.sha }} | ||
${{ env.BASE_IMAGE }}:latest | ||
push: true | ||
build-args: NEXT_PUBLIC_BASE_PATH=${{ env.NEXT_PUBLIC_BASE_PATH }} | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up kubectl | ||
uses: google-github-actions/get-gke-credentials@main | ||
with: | ||
cluster_name: hosted-service | ||
location: us-central1-a | ||
credentials: ${{ secrets.GCP_SA_KEY_PRODUCTION }} | ||
|
||
- name: Set a new k8s image and apply the manifests | ||
run: .github/scripts/kustomize-apply.sh production $APP_NAME=$BASE_IMAGE:$GITHUB_SHA | ||
|
||
- name: Wait for pods to be ready | ||
run: .github/scripts/kubectl-wait-ready.sh $APP_NAME | ||
|
||
- name: Check the endpoints | ||
run: .github/scripts/npx-wait-on/run.sh $HEALTH_CHECK_URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Staging CI/CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
BASE_IMAGE: ghcr.io/graphprotocol/graph-docs-staging | ||
HEALTH_CHECK_URL: https://staging.thegraph.com/docs | ||
APP_NAME: graph-docs | ||
NEXT_PUBLIC_BASE_PATH: /docs | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: Jannis | ||
password: ${{ secrets.GH_ACCESS_TOKEN_JANNIS }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . # required to respect .dockerignore | ||
cache-from: type=registry,ref=${{ env.BASE_IMAGE }}:latest | ||
cache-to: type=inline | ||
secrets: npmrc=//registry.npmjs.org/:_authToken=${{ secrets.NPM_SECRET_TOKEN }} | ||
tags: | | ||
${{ env.BASE_IMAGE }}:${{ github.sha }} | ||
${{ env.BASE_IMAGE }}:latest | ||
push: true | ||
build-args: NEXT_PUBLIC_BASE_PATH=${{ env.NEXT_PUBLIC_BASE_PATH }} | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up kubectl | ||
uses: google-github-actions/get-gke-credentials@main | ||
with: | ||
cluster_name: hosted-service | ||
location: us-central1-a | ||
credentials: ${{ secrets.GCP_SA_KEY_STAGING }} | ||
|
||
- name: Set a new k8s image and apply the manifests | ||
run: .github/scripts/kustomize-apply.sh staging $APP_NAME=$BASE_IMAGE:$GITHUB_SHA | ||
|
||
- name: Wait for pods to be ready | ||
run: .github/scripts/kubectl-wait-ready.sh $APP_NAME | ||
|
||
- name: Check the endpoints | ||
run: .github/scripts/npx-wait-on/run.sh $HEALTH_CHECK_URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yalc | ||
yalc.lock | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
.next | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: graph-docs | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: graph-docs | ||
template: | ||
metadata: | ||
labels: | ||
app: graph-docs | ||
spec: | ||
imagePullSecrets: | ||
- name: docker-registry | ||
containers: | ||
- name: app | ||
image: graph-docs | ||
ports: | ||
- name: http | ||
containerPort: 80 | ||
protocol: TCP | ||
readinessProbe: | ||
httpGet: | ||
port: http |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
resources: | ||
- deployment.yaml | ||
- service.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: graph-docs | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: graph-docs | ||
ports: | ||
- name: http | ||
port: 80 | ||
protocol: TCP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gcloud container clusters get-credentials hosted-service --project the-graph-production --zone us-central1-a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: graph-docs | ||
spec: | ||
replicas: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: networking.k8s.io/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: graph-docs | ||
annotations: | ||
kubernetes.io/ingress.class: nginx | ||
spec: | ||
rules: | ||
- host: thegraph.com | ||
http: | ||
paths: | ||
- path: /docs | ||
backend: | ||
serviceName: graph-docs | ||
servicePort: http |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
bases: | ||
- ../base | ||
resources: | ||
- ingress.yaml | ||
patchesStrategicMerge: | ||
- deployment.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gcloud container clusters get-credentials hosted-service --project the-graph-staging --zone us-central1-a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: networking.k8s.io/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: graph-docs | ||
annotations: | ||
kubernetes.io/ingress.class: nginx | ||
spec: | ||
rules: | ||
- host: staging.thegraph.com | ||
http: | ||
paths: | ||
- path: /docs | ||
backend: | ||
serviceName: graph-docs | ||
servicePort: http |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
bases: | ||
- ../base | ||
resources: | ||
- ingress.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
engine-strict=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.yalc | ||
.next | ||
/out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"semi": false, | ||
"printWidth": 120 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.terraform* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Graph Docs Terraform configs | ||
|
||
## Setup | ||
|
||
Initialize terraform and apply: | ||
|
||
``` | ||
terraform init | ||
terraform apply | ||
``` | ||
|
||
Get service account JSON keys and add as github repo secrets: | ||
|
||
1. `GCP_SA_KEY_STAGING` | ||
|
||
``` | ||
terraform show -json | jq -r '.values.root_module.child_modules[] | select(.address=="module.staging") | .resources[] | select(.address=="module.staging.google_service_account_key.graph-docs-ci-cd") | .values.private_key' | base64 -d | ||
``` | ||
|
||
2. `GCP_SA_KEY_PRODUCTION` | ||
|
||
``` | ||
terraform show -json | jq -r '.values.root_module.child_modules[] | select(.address=="module.production") | .resources[] | select(.address=="module.production.google_service_account_key.graph-docs-ci-cd") | .values.private_key' | base64 -d | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
# gsutil mb gs://tf-state-graph-docs | ||
terraform { | ||
backend "gcs" { | ||
bucket = "tf-state-graph-docs" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module staging { | ||
source = "./module" | ||
project = "the-graph-staging" | ||
} | ||
|
||
module production { | ||
source = "./module" | ||
project = "the-graph-production" | ||
} |
Oops, something went wrong.