Skip to content

Commit

Permalink
feat(ci): add circle ci configuration
Browse files Browse the repository at this point in the history
- Setup Firebase
- Add Circle CI configuration
- Add CI job to deploy to Firebase Hosting
  • Loading branch information
ricardochl committed May 24, 2024
1 parent e9a4714 commit b8d3388
Show file tree
Hide file tree
Showing 7 changed files with 7,414 additions and 482 deletions.
124 changes: 104 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,114 @@
# See: https://circleci.com/docs/configuration-reference
version: 2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/jobs-steps/#jobs-overview & https://circleci.com/docs/configuration-reference/#jobs
jobs:
say-hello:
# Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/executor-intro/ & https://circleci.com/docs/configuration-reference/#executor-job
docker:
# Specify the version you desire here
# See: https://circleci.com/developer/images/image/cimg/base
- image: cimg/base:current
# Settings common to each job
job_defaults: &job_defaults
working_directory: ~/angular-docs-es
docker:
- image: cimg/node:lts-browsers

orbs:
node: circleci/[email protected]
build-tools: circleci/[email protected]
browser-tools: circleci/[email protected]

commands:
# Command for checking out the source code from GitHub. This also ensures that the source code
# can be merged to the main branch without conflicts.
checkout_and_rebase:
description: Checkout and verify clean merge with main
steps:
- checkout
- run:
name: Set git user.name and user.email for rebase.
# User is required for rebase.
command: |
git config user.name "ricardochl"
git config user.email "[email protected]"
- build-tools/merge-with-parent:
parent: main
setup:
description: 'Set up executor'
steps:
- attach_workspace:
at: ~/
setup_firebase_auth:
description: 'Set up Firebase authentication'
steps:
- run:
name: Create a $GOOGLE_APPLICATION_CREDENTIALS environment variable
command: |
# Create google_service_account.json file
echo $GSA_KEY > google_service_account.json
# Set the variable at runtime
export GOOGLE_APPLICATION_CREDENTIALS=google_service_account.json
# Add steps to the job
# See: https://circleci.com/docs/jobs-steps/#steps-overview & https://circleci.com/docs/configuration-reference/#steps
# ----------------------------------
# Job definitions.
# ----------------------------------

jobs:
# ----------------------------------
# initialize job
# ----------------------------------
initialize:
<<: *job_defaults
steps:
# Checkout the code as the first step.
- checkout_and_rebase
- node/install-packages
- persist_to_workspace:
root: ~/
paths:
- angular-docs-es
# -----------------------------------
# Build job.
# -----------------------------------
build:
<<: *job_defaults
steps:
- setup
- checkout
- run:
name: "Say hello"
command: "echo Hello, World!"
name: Build project in CI mode (pre build)
command: npm run build:ci
# - run:
# name: Installing packages
# working_directory: ./build
# command: yarn install
# - run:
# name: Build adev-es docs
# working_directory: ./build
# command: yarn bazel build //adev:build --fast_adev --local_ram_resources="HOST_RAM*.90" --jobs=1
# - persist_to_workspace:
# root: ~/
# paths:
# - angular-docs-es/build/dist/bin/adev/build/browser

# -----------------------------------
# Firebase deploy to staging job.
# -----------------------------------
firebase-deploy-staging:
<<: *job_defaults
steps:
- setup
- setup_firebase_auth
# - run:
# name: 'Deploy Main Branch to Firebase'
# command: |
# npm run deploy:staging

# Orchestrate jobs using workflows
# See: https://circleci.com/docs/workflows/ & https://circleci.com/docs/configuration-reference/#workflows
workflows:
say-hello-workflow: # This is the name of the workflow, feel free to change it to better match your workflow.
# Inside the workflow, you define the jobs you want to run.
build-workflow:
jobs:
- say-hello
- initialize
- build:
requires:
- initialize
- firebase-deploy-staging:
# filters:
# branches:
# only:
# - main
requires:
- build
16 changes: 16 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"projects": {
"default": "angular-hispano-staging",
"staging": "angular-hispano-staging"
},
"targets": {
"angular-hispano-staging": {
"hosting": {
"staging": [
"angular-hispano-docs-staging"
]
}
}
},
"etags": {}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ yarn-error.log
# System files
.DS_Store
Thumbs.db

# Firebase Caching
.firebase
17 changes: 17 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"hosting": {
"target": "staging",
"public": "build/dist/bin/adev/build/browser",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Loading

0 comments on commit b8d3388

Please sign in to comment.