Skip to content

Commit adc71e6

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 adc71e6

File tree

5 files changed

+149
-22
lines changed

5 files changed

+149
-22
lines changed

.circleci/config.yml

Lines changed: 110 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,120 @@
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+
setup-bazel:
37+
description: |
38+
Setup the Bazel build system
39+
steps:
40+
- run:
41+
name: Add Bazel Apt repository
42+
command: |
43+
sudo apt install curl gnupg
44+
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
45+
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
46+
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
47+
- run:
48+
name: Install Bazel from Apt
49+
command: sudo apt update && sudo apt install bazel-5.0.0
50+
51+
setup_firebase_auth:
52+
description: 'Set up Firebase authentication'
53+
steps:
54+
- run:
55+
name: Create a $GOOGLE_APPLICATION_CREDENTIALS environment variable
56+
command: |
57+
# Set the variable at runtime because CircleCI doesn't support interpolation when setting environment variables.
58+
echo 'export GOOGLE_APPLICATION_CREDENTIALS="$HOME"/google_service_account.json' >> "$BASH_ENV"
59+
- run:
60+
name: Create GSA key JSON file
61+
command: echo $GSA_KEY > $GOOGLE_APPLICATION_CREDENTIALS
62+
63+
# ----------------------------------
64+
# Job definitions.
65+
# ----------------------------------
66+
767
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
68+
# ----------------------------------
69+
# initialize job
70+
# ----------------------------------
71+
initialize:
72+
<<: *job_defaults
73+
steps:
74+
- checkout_and_rebase
75+
- node/install-packages
76+
- persist_to_workspace:
77+
root: ~/
78+
paths:
79+
- angular-docs-es
80+
# -----------------------------------
81+
# Build job.
82+
# -----------------------------------
83+
build:
84+
<<: *job_defaults
1885
steps:
19-
# Checkout the code as the first step.
86+
- setup
2087
- checkout
88+
- setup-bazel
89+
# - run: npm run build
90+
# - persist_to_workspace:
91+
# root: ~/
92+
# paths:
93+
# - angular-docs-es/build/dist/bin/adev/build/browser
94+
95+
# -----------------------------------
96+
# Firebase deploy to staging job.
97+
# -----------------------------------
98+
firebase-deploy-staging:
99+
<<: *job_defaults
100+
steps:
101+
- setup
102+
- setup_firebase_auth
21103
- run:
22-
name: "Say hello"
23-
command: "echo Hello, World!"
104+
name: 'Deploy Main Branch to Firebase'
105+
command: |
106+
npm run deploy:staging
24107
25-
# Orchestrate jobs using workflows
26-
# See: https://circleci.com/docs/workflows/ & https://circleci.com/docs/configuration-reference/#workflows
27108
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.
109+
build-workflow:
30110
jobs:
31-
- say-hello
111+
- initialize
112+
- build:
113+
requires:
114+
- initialize
115+
- firebase-deploy-staging:
116+
filters:
117+
branches:
118+
only:
119+
- main
120+
requires:
121+
- 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)