Skip to content

Commit b2f7484

Browse files
committed
feat(ci): add circle ci configuration
- Setup Firebase - Add Circle CI configuration - Add CI job to deploy to Firebase Hosting
1 parent e9a4714 commit b2f7484

File tree

5 files changed

+134
-22
lines changed

5 files changed

+134
-22
lines changed

.circleci/config.yml

Lines changed: 95 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,105 @@
22
# See: https://circleci.com/docs/configuration-reference
33
version: 2.1
44

5-
# Define a job to be invoked later in a workflow.
6-
# See: https://circleci.com/docs/jobs-steps/#jobs-overview & https://circleci.com/docs/configuration-reference/#jobs
5+
# Settings common to each job
6+
job_defaults: &job_defaults
7+
working_directory: ~/angular-docs-es
8+
docker:
9+
- image: cimg/node:lts-browsers
10+
11+
orbs:
12+
node: circleci/[email protected]
13+
build-tools: circleci/[email protected]
14+
browser-tools: circleci/[email protected]
15+
16+
commands:
17+
# Command for checking out the source code from GitHub. This also ensures that the source code
18+
# can be merged to the main branch without conflicts.
19+
checkout_and_rebase:
20+
description: Checkout and verify clean merge with main
21+
steps:
22+
- checkout
23+
- run:
24+
name: Set git user.name and user.email for rebase.
25+
# User is required for rebase.
26+
command: |
27+
git config user.name "ricardochl"
28+
git config user.email "[email protected]"
29+
- build-tools/merge-with-parent:
30+
parent: main
31+
setup:
32+
description: 'Set up executor'
33+
steps:
34+
- attach_workspace:
35+
at: ~/
36+
37+
setup_firebase_auth:
38+
description: 'Set up Firebase authentication'
39+
steps:
40+
- run:
41+
name: Create a $GOOGLE_APPLICATION_CREDENTIALS environment variable
42+
command: |
43+
# Set the variable at runtime because CircleCI doesn't support interpolation when setting environment variables.
44+
echo 'export GOOGLE_APPLICATION_CREDENTIALS="$HOME"/google_service_account.json' >> "$BASH_ENV"
45+
- run:
46+
name: Create GSA key JSON file
47+
command: echo $GSA_KEY > $GOOGLE_APPLICATION_CREDENTIALS
48+
49+
# ----------------------------------
50+
# Job definitions.
51+
# ----------------------------------
52+
753
jobs:
8-
say-hello:
9-
# Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub.
10-
# See: https://circleci.com/docs/executor-intro/ & https://circleci.com/docs/configuration-reference/#executor-job
11-
docker:
12-
# Specify the version you desire here
13-
# See: https://circleci.com/developer/images/image/cimg/base
14-
- image: cimg/base:current
15-
16-
# Add steps to the job
17-
# See: https://circleci.com/docs/jobs-steps/#steps-overview & https://circleci.com/docs/configuration-reference/#steps
54+
# ----------------------------------
55+
# initialize job
56+
# ----------------------------------
57+
initialize:
58+
<<: *job_defaults
1859
steps:
19-
# Checkout the code as the first step.
60+
- checkout_and_rebase
61+
- node/install-packages
62+
- persist_to_workspace:
63+
root: ~/
64+
paths:
65+
- angular-docs-es
66+
# -----------------------------------
67+
# Build job.
68+
# -----------------------------------
69+
build:
70+
<<: *job_defaults
71+
steps:
72+
- setup
2073
- checkout
74+
# - run: npm run build
75+
# - persist_to_workspace:
76+
# root: ~/
77+
# paths:
78+
# - angular-docs-es/build/dist/bin/adev/build/browser
79+
80+
# -----------------------------------
81+
# Firebase deploy to staging job.
82+
# -----------------------------------
83+
firebase-deploy-staging:
84+
<<: *job_defaults
85+
steps:
86+
- setup
87+
- setup_firebase_auth
2188
- run:
22-
name: "Say hello"
23-
command: "echo Hello, World!"
89+
name: 'Deploy Main Branch to Firebase'
90+
command: |
91+
npm run deploy:staging
2492
25-
# Orchestrate jobs using workflows
26-
# See: https://circleci.com/docs/workflows/ & https://circleci.com/docs/configuration-reference/#workflows
2793
workflows:
28-
say-hello-workflow: # This is the name of the workflow, feel free to change it to better match your workflow.
29-
# Inside the workflow, you define the jobs you want to run.
94+
build-workflow:
3095
jobs:
31-
- say-hello
96+
- initialize
97+
- build:
98+
requires:
99+
- initialize
100+
- firebase-deploy-staging:
101+
filters:
102+
branches:
103+
only:
104+
- main
105+
requires:
106+
- build

.firebaserc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"projects": {
3+
"default": "angular-hispano-staging",
4+
"staging": "angular-hispano-staging"
5+
},
6+
"targets": {
7+
"angular-hispano-staging": {
8+
"hosting": {
9+
"staging": [
10+
"angular-hispano-docs-staging"
11+
]
12+
}
13+
}
14+
},
15+
"etags": {}
16+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ yarn-error.log
1919
# System files
2020
.DS_Store
2121
Thumbs.db
22+
23+
# Firebase Caching
24+
.firebase

firebase.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"hosting": {
3+
"target": "staging",
4+
"public": "build/dist/bin/adev/build/browser",
5+
"ignore": [
6+
"firebase.json",
7+
"**/.*",
8+
"**/node_modules/**"
9+
],
10+
"rewrites": [
11+
{
12+
"source": "**",
13+
"destination": "/index.html"
14+
}
15+
]
16+
}
17+
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"build": "zx tools/build.mjs",
99
"start": "zx tools/watch.mjs",
10-
"update-origin": "zx tools/update-origin.mjs"
11-
},
10+
"update-origin": "zx tools/update-origin.mjs",
11+
"deploy:staging": "firebase use staging && firebase deploy --only hosting:staging"
12+
},
1213
"keywords": [],
1314
"author": "",
1415
"license": "ISC",

0 commit comments

Comments
 (0)