Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

Commit

Permalink
Fixed #312, simplify firebase deploy (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhelmer authored Apr 22, 2022
1 parent 7dcdcfc commit 7fcf218
Show file tree
Hide file tree
Showing 3 changed files with 38,215 additions and 223 deletions.
60 changes: 18 additions & 42 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,14 @@ jobs:
steps:
# Checkout the code as the first step.
- checkout
# Build while on the deploy branch. Note - this will only be checked in if the deploy-branch-update runs.
- run:
name: Configure git for ci-build
command: |
git config user.email "ci-build@rally-web-platform"
git config user.name "ci-build"
- run:
name: Checkout deploy branch and merge onto current branch
command: git checkout deploy && git merge --no-ff -m"automated merge to deploy branch" ${CIRCLE_BRANCH}
# Next, the node orb's install-packages step will install the dependencies from a package.json.
# The orb install-packages step will also automatically cache them for faster future runs.
- node/install-packages
- run:
name: Run lint
command: npm run lint:functions # TODO - fix the other linters https://github.com/mozilla-rally/rally-web-platform/issues/112
- run:
name: Run build
command: npm run build
# Save this workspace, will be archived if tests pass before deploy.
- persist_to_workspace:
root: .
paths:
Expand All @@ -59,33 +49,22 @@ jobs:
path: ./screenshots
- store_artifacts:
path: ./functions/coverage
# This pushes our deployable assets to a branch, for SRE to use in deploying to stage and prod.
deploy-branch-update:

# This archives our deployable assets, before deploy happens.
archive-site:
docker:
- image: cimg/node:15.1
# re-attach workspace from before tests ran
steps:
- attach_workspace:
at: .
- run:
name: Set up ssh known_hosts # https://circleci.com/docs/2.0/gh-bb-integration/
name: Archive Firebase before deploy
command: |
mkdir -p ~/.ssh
echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
' >> ~/.ssh/known_hosts
- run:
name: Add website build output to git
command: |
git checkout functions/package-lock.json
git add -f functions/lib/ build/
- add_ssh_keys:
fingerprints:
- "ab:41:e3:9b:de:0b:ed:6d:fc:d1:58:c0:9e:a9:e6:dd"
- run:
name: Commit build artifacts to deploy branch
command: git diff-index --quiet HEAD || git commit -m "adding build output to deploy branch" functions/lib build/
- run:
name: Push deploy branch to origin
command: git fetch origin && git merge -s ours deploy && git push origin deploy
zip -r rally-web-platform.zip ./ -i build/\* functions/lib/\* firebase.json firestore.rules
- store_artifacts:
path: ./rally-web-platform.zip

#rally-web platform deploy block. Env variables are defined in rally-web context
site-deploy:
parameters:
Expand All @@ -100,23 +79,20 @@ jobs:
#default: $GCLOUD_SERVICE_KEY
docker:
- image: cimg/node:15.1
# re-attach workspace from before tests ran
steps:
- checkout
- run:
name: Check out the deploy branch.
command: git checkout deploy && git pull --rebase origin deploy
- attach_workspace:
at: .
- run:
name: Create Service Account key JSON.
command: echo << parameters.service_key >> | base64 --decode --ignore-garbage > "$HOME"/gcloud.json
- run:
name: Install Firebase Tools needed for deploy.
command: npm install firebase-tools firebase-functions
- run:
name: Configure Firebase for the deployment project name.
command: GOOGLE_APPLICATION_CREDENTIALS="$HOME"/gcloud.json ./node_modules/.bin/firebase use --add << parameters.project_name >> && cp config/firebase.config.<< parameters.project_config >>.json build/firebase.config.json
- run:
name: Firebase Deploy.
command: GOOGLE_APPLICATION_CREDENTIALS="$HOME"/gcloud.json ./node_modules/.bin/firebase deploy --project << parameters.project_name >>

workflows:
# Below is the definition of your workflow.
# Inside the workflow, you provide the jobs you want to run, e.g this workflow runs the build-and-test job above.
Expand All @@ -129,23 +105,23 @@ workflows:
filters:
tags:
only: /.*/
# For running simple node tests, you could optionally use the node/test job from the orb to replicate and replace the job above in fewer lines.
# - node/test
- deploy-branch-update:

- archive-site:
requires:
- build-and-test
filters:
tags:
only: /.*/
branches:
only: master

- site-deploy: # This deploys to our stage site at https://stage.rally-web.nonprod.dataops.mozgcp.net
context: rally-web
project_name: $PROJECT_ID_STAGE
project_config: rally-web-stage
service_key: $GCLOUD_SERVICE_KEY
requires:
- deploy-branch-update
- archive-site
filters:
tags:
only: /.*/
Expand Down
Loading

0 comments on commit 7fcf218

Please sign in to comment.