Skip to content

Commit 10e299c

Browse files
ricardochlSplaktar
authored andcommitted
feat(ci): add circle ci configuration
- Setup Firebase - Add Circle CI configuration - Add CI job to deploy to Firebase Hosting - Update build script
1 parent e9a4714 commit 10e299c

File tree

8 files changed

+7418
-482
lines changed

8 files changed

+7418
-482
lines changed

.circleci/config.yml

Lines changed: 100 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,110 @@
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
7-
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
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]
1515

16-
# Add steps to the job
17-
# See: https://circleci.com/docs/jobs-steps/#steps-overview & https://circleci.com/docs/configuration-reference/#steps
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
1821
steps:
19-
# Checkout the code as the first step.
2022
- checkout
2123
- run:
22-
name: "Say hello"
23-
command: "echo Hello, World!"
24+
name: Set git user.name and user.email for rebase.
25+
# User is required for rebase.
26+
command: |
27+
git config user.name "Admin"
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_firebase_auth:
37+
description: 'Set up Firebase authentication'
38+
steps:
39+
- run:
40+
name: Create a google_service_account.json
41+
command: |
42+
echo $GSA_KEY > $GOOGLE_APPLICATION_CREDENTIALS
43+
44+
# ----------------------------------
45+
# Job definitions.
46+
# ----------------------------------
47+
48+
jobs:
49+
# ----------------------------------
50+
# initialize job
51+
# ----------------------------------
52+
initialize:
53+
<<: *job_defaults
54+
steps:
55+
- checkout_and_rebase
56+
- node/install-packages
57+
- persist_to_workspace:
58+
root: ~/
59+
paths:
60+
- angular-docs-es
61+
# -----------------------------------
62+
# Build job.
63+
# -----------------------------------
64+
build:
65+
<<: *job_defaults
66+
steps:
67+
- setup
68+
- checkout
69+
- run:
70+
name: Build project in CI mode (pre build)
71+
command: npm run build:ci
72+
- run:
73+
name: Installing packages
74+
working_directory: ./build
75+
command: yarn install
76+
- run:
77+
name: Build adev-es docs
78+
working_directory: ./build
79+
command: yarn bazel build //adev:build --fast_adev --local_ram_resources="HOST_RAM*.90" --jobs=1
80+
- persist_to_workspace:
81+
root: ~/
82+
paths:
83+
- angular-docs-es/build/dist/bin/adev/build/browser
84+
85+
# -----------------------------------
86+
# Firebase deploy to staging job.
87+
# -----------------------------------
88+
firebase-deploy-staging:
89+
<<: *job_defaults
90+
steps:
91+
- setup
92+
- setup_firebase_auth
93+
- run:
94+
name: 'Deploy Main Branch to Firebase Hosting'
95+
command: |
96+
npm run deploy:staging
2497
25-
# Orchestrate jobs using workflows
26-
# See: https://circleci.com/docs/workflows/ & https://circleci.com/docs/configuration-reference/#workflows
2798
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.
99+
build-workflow:
30100
jobs:
31-
- say-hello
101+
- initialize
102+
- build:
103+
requires:
104+
- initialize
105+
- firebase-deploy-staging:
106+
filters:
107+
branches:
108+
only:
109+
- main
110+
requires:
111+
- 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

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ $ npm run build
9999

100100
Cuando se completa la compilación, el resultado de la compilación se envía al directorio `build/dist/bin/adev/build`. Puedes configurar un servidor de desarrollo con tu herramienta favorita y comprobar los sitios construidos.
101101

102+
Construye el proyecto en CI
103+
104+
```
105+
$ npm run build:ci
106+
```
107+
108+
La compilación del proyecto en CI funciona de manera diferente, primero ejecutamos el comando `npm run build:ci`, este comando realizará un `pre-built` del proyecto, es decir que no construirá la documentación y solo creará el directorio `build` y copiará los archivos necesarios. La construcción de la documentación se realizará directamente en la configuración de CI.
109+
102110
## Gracias por tu colaboración!
103111

104112
Esperamos que te unas a nosotros en este esfuerzo por hacer que la documentación de Angular sea más accesible para la comunidad hispanohablante.

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+
}

0 commit comments

Comments
 (0)