Skip to content

Commit 964188e

Browse files
committed
feat: Add staging workflow
1 parent 548aab5 commit 964188e

File tree

3 files changed

+84
-35
lines changed

3 files changed

+84
-35
lines changed

Diff for: .circleci/config.yml

+50-26
Original file line numberDiff line numberDiff line change
@@ -35,39 +35,45 @@ jobs: # a collection of steps
3535
- store_artifacts:
3636
path: ~/tmp/reports/eslint
3737

38-
version: # version the project
38+
build_without_version: # build the project - requires dependencies to have been installed
3939
executor: node-project
4040
steps:
4141
- checkout
4242
- restore_cache:
4343
key: dependency-cache-{{ .Environment.CIRCLE_WORKFLOW_ID }}
44-
- run:
45-
name: Add Git User details
46-
command: |
47-
git config --global user.email "ripixel+ci@gmail.com"
48-
git config --global user.name "CircleCi"
49-
- run:
50-
name: Bump version and generate changelog
51-
command: npm run release:ci
52-
- save_cache: # special step to save the changelog
44+
- restore_cache:
5345
key: changelog-cache-{{ .Environment.CIRCLE_WORKFLOW_ID }}
46+
- run: # run build
47+
name: Build
48+
command: npm run build
49+
- store_artifacts: # for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
50+
path: public
51+
prefix: public
52+
- save_cache: # special step to save the public cache and deploy files
53+
key: deploy-cache-{{ .Environment.CIRCLE_WORKFLOW_ID }}
5454
paths:
55-
- ~/tmp/CHANGELOG.md
55+
- ~/tmp/public
56+
- ~/tmp/.firebaserc
57+
- ~/tmp/firebase.json
5658
- ~/tmp/package-lock.json
57-
- ~/tmp/package.json
5859

59-
build: # build the project - requires dependencies to have been installed
60+
build_and_version:
6061
executor: node-project
6162
steps:
6263
- checkout
6364
- restore_cache:
6465
key: dependency-cache-{{ .Environment.CIRCLE_WORKFLOW_ID }}
65-
- restore_cache:
66-
key: changelog-cache-{{ .Environment.CIRCLE_WORKFLOW_ID }}
66+
- run:
67+
name: Add Git User details
68+
command: |
69+
git config --global user.email "ripixel+ci@gmail.com"
70+
git config --global user.name "CircleCi"
71+
- run:
72+
name: Bump version and generate changelog
73+
command: npm run release:ci
6774
- run: # run build
6875
name: Build
69-
command: |
70-
npm run build
76+
command: npm run build
7177
- store_artifacts: # for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
7278
path: public
7379
prefix: public
@@ -79,16 +85,27 @@ jobs: # a collection of steps
7985
- ~/tmp/firebase.json
8086
- ~/tmp/package-lock.json
8187

82-
deploy_to_firebase: # deploy the project to prod - SHOULD ONLY BE RUN ON MASTER BRANCH
88+
deploy_to_firebase_prod: # deploy the project to prod - SHOULD ONLY BE RUN ON MASTER BRANCH
89+
executor: node-project
90+
steps:
91+
- restore_cache: # restore the /public folder and associated deploy files
92+
key: deploy-cache-{{ .Environment.CIRCLE_WORKFLOW_ID }}
93+
- restore_cache: # special step to restore the dependency cache
94+
key: dependency-cache-{{ .Environment.CIRCLE_WORKFLOW_ID }}
95+
- run:
96+
name: Deploy to Firebase Production Hosting
97+
command: ./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN" --only hosting:production
98+
99+
deploy_to_firebase_stg: # deploy the project to staging - SHOULD ONLY BE RUN ON STAGING BRANCH
83100
executor: node-project
84101
steps:
85102
- restore_cache: # restore the /public folder and associated deploy files
86103
key: deploy-cache-{{ .Environment.CIRCLE_WORKFLOW_ID }}
87104
- restore_cache: # special step to restore the dependency cache
88105
key: dependency-cache-{{ .Environment.CIRCLE_WORKFLOW_ID }}
89106
- run:
90-
name: Deploy to Firebase Hosting
91-
command: ./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN"
107+
name: Deploy to Firebase Staging Hosting
108+
command: ./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN" --only hosting:staging
92109

93110
workflows:
94111
version: 2
@@ -98,21 +115,28 @@ workflows:
98115
- lint:
99116
requires:
100117
- install_deps
101-
- version:
118+
- build_without_version:
119+
filters:
120+
branches:
121+
ignore: master
122+
requires:
123+
- install_deps
124+
- build_and_version:
102125
filters:
103126
branches:
104127
only: master
105128
requires:
129+
- install_deps
106130
- lint
107-
- build:
131+
- deploy_to_firebase_prod:
108132
filters:
109133
branches:
110134
only: master
111135
requires:
112-
- version
113-
- deploy_to_firebase:
136+
- build_and_version
137+
- deploy_to_firebase_stg:
114138
filters:
115139
branches:
116-
only: master
140+
only: staging
117141
requires:
118-
- build
142+
- build_without_version

Diff for: .firebaserc

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
{
22
"projects": {
33
"default": "ripixel-f24bf"
4+
},
5+
"targets": {
6+
"ripixel-f24bf": {
7+
"hosting": {
8+
"production": [
9+
"ripixel-f24bf"
10+
],
11+
"staging": [
12+
"ripixel-staging"
13+
]
14+
}
15+
}
416
}
517
}

Diff for: firebase.json

+22-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
{
2-
"hosting": {
3-
"public": "./public",
4-
"ignore": [
5-
"firebase.json",
6-
"**/.*",
7-
"**/node_modules/**"
8-
],
9-
"cleanUrls": true
10-
}
2+
"hosting": [
3+
{
4+
"target": "production",
5+
"public": "./public",
6+
"ignore": [
7+
"firebase.json",
8+
"**/.*",
9+
"**/node_modules/**"
10+
],
11+
"cleanUrls": true
12+
},
13+
{
14+
"target": "staging",
15+
"public": "./public",
16+
"ignore": [
17+
"firebase.json",
18+
"**/.*",
19+
"**/node_modules/**"
20+
],
21+
"cleanUrls": true
22+
}
23+
]
1124
}

0 commit comments

Comments
 (0)