Skip to content

Commit 3109c1f

Browse files
Merge pull request #10 from howtographql/ci-cd
Ci cd
2 parents 3fbe208 + 6c59401 commit 3109c1f

File tree

22 files changed

+12256
-113
lines changed

22 files changed

+12256
-113
lines changed

.circleci/config.yml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2.1
6+
7+
commands:
8+
deploy-now-sh:
9+
description: "A command to deploy to now.sh."
10+
steps:
11+
- checkout
12+
- restore_cache:
13+
name: Restore Yarn Package Cache
14+
keys:
15+
- yarn-packages-{{ checksum "yarn.lock" }}
16+
- run:
17+
name: Install Dependencies
18+
command: yarn install --frozen-lockfile
19+
- save_cache:
20+
name: Save Yarn Package Cache
21+
key: yarn-packages-{{ checksum "yarn.lock" }}
22+
paths:
23+
- ~/.cache/yarn
24+
- run: yarn server build && yarn deploy
25+
26+
27+
jobs:
28+
production:
29+
docker:
30+
- image: circleci/node:8.10.0
31+
environment:
32+
STAGE: production
33+
NOW_ALIAS: https://api-prod.howtographql.now.sh
34+
working_directory: ~/repo
35+
steps:
36+
- deploy-now-sh
37+
38+
staging:
39+
docker:
40+
- image: circleci/node:8.10.0
41+
environment:
42+
STAGE: staging
43+
NOW_ALIAS: https://api-staging.howtographql.now.sh
44+
working_directory: ~/repo
45+
steps:
46+
- deploy-now-sh
47+
48+
publish-apollo:
49+
docker:
50+
# specify the version you desire here
51+
- image: circleci/node:8.10.0
52+
working_directory: ~/repo
53+
steps:
54+
- checkout
55+
- run: yarn install
56+
# Start the GraphQL server. If a different command is used to
57+
# start the server, use it in place of `npm start` here.
58+
- run:
59+
name: Starting server
60+
command: yarn server start
61+
background: true
62+
# make sure the server has enough time to start up before running
63+
# commands against it
64+
- run: sleep 5
65+
# When running on the 'master' branch, push the latest version
66+
# of the schema to Apollo Engine.
67+
- run: |
68+
yarn apollo service:push --tag="${CIRCLE_BRANCH}"
69+
70+
workflows:
71+
version: 2
72+
deploy-publish:
73+
jobs:
74+
- production:
75+
filters:
76+
branches:
77+
only:
78+
- master
79+
- staging:
80+
filters:
81+
branches:
82+
ignore:
83+
- master
84+
# - publish-apollo

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.next
2+
node_modules
3+
generated

.nowignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.next
2+
node_modules

.prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"bracketSpacing": true,
4+
"semi": true,
5+
"trailingComma": "all"
6+
}

.scripts/deploy-now.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
# ENV Variables, Note: ACCESS_TOKEN and NOW_TOKEN in gitlab-ci
6+
ORIGIN='*'
7+
# NOW config
8+
TEAM=howtographql
9+
PROJECT=api
10+
ALIAS=$NOW_ALIAS
11+
12+
export PATH="./node_modules/.bin:$PATH"
13+
# 1. Wait for deployment ready
14+
URL=$(now --target $STAGE -e STAGE=$STAGE --token "$NOW_TOKEN")
15+
# URL=$(now --target $STAGE -e STAGE=$STAGE -e ENGINE_TAG=${CIRCLE_BRANCH:-staging} --token "$NOW_TOKEN" --scope $TEAM)
16+
# 2. Alias
17+
now alias set "$URL" "$ALIAS" --token "$NOW_TOKEN" --scope $TEAM
18+
# 3. Purge old services
19+
now remove $PROJECT --yes --safe --token "$NOW_TOKEN" --scope $TEAM || true
20+
21+
# 5. Log results
22+
now ls $PROJECT --token "$NOW_TOKEN" --scope $TEAM || true

.scripts/deploy.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bash ./.scripts/deploy-now.sh

netlify.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[build]
2+
command = "yarn site build"
3+
publish = "./oss/public"
4+
5+
[build.environment]
6+
NODE_VERSION = "v11.14.0"
7+
YARN_VERSION = "1.15.2"

now.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"version": 2,
3+
"name": "api",
4+
"scope": "howtographql",
5+
"alias": "howtogaphql.now.sh",
6+
"env": {
7+
"NODE_ENV": "dev"
8+
},
9+
"builds": [
10+
{
11+
"src": "packages/server/dist/src/index.js",
12+
"use": "@now/node-server@canary"
13+
}
14+
],
15+
"routes": [
16+
{
17+
"src": "/(.*)",
18+
"dest": "packages/server/dist/src/index.js"
19+
}
20+
]
21+
}

package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
"license": "MIT",
88
"private": true,
99
"scripts": {
10-
"lerna": "lerna",
1110
"dev": "npm-run-all --parallel 'site develop' 'server dev'",
1211
"site": "yarn workspace @howtographql/oss",
1312
"server": "yarn workspace @howtographql/server",
1413
"theme": "yarn workspace @howtographql/gatsby-theme",
15-
"publish": "lerna publish --skip-git"
14+
"publish": "lerna publish --skip-git",
15+
"lerna": "lerna",
16+
"deploy": "npm-run-all --parallel deploy:server",
17+
"deploy:server": "bash ./.scripts/deploy.sh"
1618
},
1719
"workspaces": {
1820
"packages": [
@@ -21,6 +23,8 @@
2123
]
2224
},
2325
"devDependencies": {
26+
"apollo": "^2.10.0",
27+
"now": "^15.2.0",
2428
"npm-run-all": "^4.1.5"
2529
}
2630
}

packages/gatsby-theme/src/components/templates/TutorialOverview.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react";
22
import { graphql } from "gatsby";
33
import Layout from "../layout";
4-
import Chapter from "../Chapter";
4+
import Chapter from "../chapter";
55
import { TutorialOverviewQuery } from "src/graphqlTypes";
66
import { Author } from "../Author";
77

packages/server/.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.DS_Store
22
node_modules
33
*.log
4-
.yoga
54
dist

0 commit comments

Comments
 (0)