Skip to content

Commit ad4fb23

Browse files
initial setup
1 parent 3fbe208 commit ad4fb23

File tree

17 files changed

+226
-84
lines changed

17 files changed

+226
-84
lines changed

.circleci/config.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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
6+
7+
jobs:
8+
production:
9+
docker:
10+
- image: circleci/node:8.10.0
11+
environment:
12+
STAGE: production
13+
NOW_PROJECT: marvel-graphql
14+
NOW_ALIAS: https://api.marvelql.com
15+
working_directory: ~/repo
16+
steps:
17+
- checkout
18+
- restore_cache:
19+
keys:
20+
- v1-dependencies-13.1.2
21+
# fallback to using the latest cache if no exact match is found
22+
- v1-dependencies-
23+
- run: yarn install
24+
- save_cache:
25+
paths:
26+
- node_modules
27+
key: v1-dependencies-13.1.2
28+
- run: yarn deploy
29+
30+
staging:
31+
docker:
32+
- image: circleci/node:8.10.0
33+
environment:
34+
STAGE: staging
35+
NOW_PROJECT: marvel-graphql-staging
36+
NOW_ALIAS: https://staging.api.marvelql.com
37+
working_directory: ~/repo
38+
steps:
39+
- checkout
40+
- restore_cache:
41+
keys:
42+
- v1-dependencies-13.1.2
43+
- v1-dependencies-
44+
- run: yarn install
45+
- save_cache:
46+
paths:
47+
- node_modules
48+
key: v1-dependencies-13.1.2
49+
- run: yarn deploy
50+
51+
publish-apollo:
52+
docker:
53+
# specify the version you desire here
54+
- image: circleci/node:8.10.0
55+
working_directory: ~/repo
56+
steps:
57+
- checkout
58+
- run: yarn install
59+
# Start the GraphQL server. If a different command is used to
60+
# start the server, use it in place of `npm start` here.
61+
- run:
62+
name: Starting server
63+
command: yarn start
64+
background: true
65+
# make sure the server has enough time to start up before running
66+
# commands against it
67+
- run: sleep 5
68+
# When running on the 'master' branch, push the latest version
69+
# of the schema to Apollo Engine.
70+
- run: |
71+
yarn apollo service:push --tag="${CIRCLE_BRANCH}"
72+
73+
workflows:
74+
version: 2
75+
deploy-publish:
76+
jobs:
77+
- production:
78+
filters:
79+
branches:
80+
only:
81+
- master
82+
- staging:
83+
filters:
84+
branches:
85+
ignore:
86+
- master
87+
- publish-apollo

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.next
2+
node_modules
3+
generated

.now/now.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": 2,
3+
"name": "server",
4+
"env": {},
5+
"builds": [
6+
{
7+
"src": "packages/server/dist/src/index.js",
8+
"use": "@now/node-server@canary"
9+
}
10+
],
11+
"routes": [
12+
{
13+
"src": "/(.*)",
14+
"dest": "packages/server/dist/src/index.js"
15+
}
16+
]
17+
}

.now/now.production.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": 2,
3+
"name": "prod",
4+
"env": {},
5+
"builds": [
6+
{
7+
"src": "packages/server/dist/src/index.js",
8+
"use": "@now/node-server@canary"
9+
}
10+
],
11+
"routes": [
12+
{
13+
"src": "/(.*)",
14+
"dest": "packages/server/dist/src/index.js"
15+
}
16+
]
17+
}

.now/now.staging.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": 2,
3+
"name": "staging",
4+
"env": {},
5+
"builds": [
6+
{
7+
"src": "packages/server/dist/src/index.js",
8+
"use": "@now/node-server@canary"
9+
}
10+
],
11+
"routes": [
12+
{
13+
"src": "/(.*)",
14+
"dest": "packages/server/dist/src/index.js"
15+
}
16+
]
17+
}

.nowignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.next
2+
node_modules

.prettierrc

Lines changed: 6 additions & 0 deletions
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

Lines changed: 22 additions & 0 deletions
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=$NOW_TEAM
9+
PROJECT=$NOW_PROJECT
10+
ALIAS=$NOW_ALIAS
11+
12+
export PATH="./node_modules/.bin:$PATH"
13+
# 1. Wait for deployment ready
14+
now --target production -A now.$STAGE.json -e STAGE=$STAGE -e ENGINE_TAG=${CIRCLE_BRANCH:-staging} --token "$NOW_TOKEN" --scope $TEAM
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# bash ./.scripts/generateEnvFile.sh
2+
bash ./.scripts/deploy-now.sh

.scripts/generateEnvFile.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
for var in $(printenv); do
3+
if [[ $var == PRISMA_* ]] ;
4+
then
5+
echo "$var" >> .env
6+
fi
7+
done

0 commit comments

Comments
 (0)