diff --git a/.circleci/config.yml b/.circleci/config.yml index 6229170..7f8b3f6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,30 +2,104 @@ # 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/node@5.2.0 + build-tools: circleci/build-tools@3.0.0 + browser-tools: circleci/browser-tools@1.4.8 - # Add steps to the job - # See: https://circleci.com/docs/jobs-steps/#steps-overview & https://circleci.com/docs/configuration-reference/#steps +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 the code as the first step. - checkout - run: - name: "Say hello" - command: "echo Hello, World!" + 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 "jr.chavarria21@gmail.com" + - 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: | + # Set the variable at runtime because CircleCI doesn't support interpolation when setting environment variables. + echo 'export GOOGLE_APPLICATION_CREDENTIALS="$HOME"/google_service_account.json' >> "$BASH_ENV" + - run: + name: Create GSA key JSON file + command: echo $GSA_KEY > $GOOGLE_APPLICATION_CREDENTIALS + +# ---------------------------------- +# Job definitions. +# ---------------------------------- + +jobs: + # ---------------------------------- + # initialize job + # ---------------------------------- + initialize: + <<: *job_defaults + steps: + - checkout_and_rebase + - node/install-packages + - persist_to_workspace: + root: ~/ + paths: + - angular-docs-es + # ----------------------------------- + # Build job. + # ----------------------------------- + build: + <<: *job_defaults + steps: + - setup + - checkout + - run: npm run build + - 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 \ No newline at end of file + - initialize + - build: + requires: + - initialize + - firebase-deploy-staging: + # filters: + # branches: + # only: + # - main + requires: + - build \ No newline at end of file diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 0000000..6f00a8c --- /dev/null +++ b/.firebaserc @@ -0,0 +1,16 @@ +{ + "projects": { + "default": "angular-hispano-staging", + "staging": "angular-hispano-staging" + }, + "targets": { + "angular-hispano-staging": { + "hosting": { + "staging": [ + "angular-hispano-docs-staging" + ] + } + } + }, + "etags": {} +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index a5a087a..f465a1b 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ yarn-error.log # System files .DS_Store Thumbs.db + +# Firebase Caching +.firebase diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..d9f1a6b --- /dev/null +++ b/firebase.json @@ -0,0 +1,17 @@ +{ + "hosting": { + "target": "staging", + "public": "build/dist/bin/adev/build/browser", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + } +} diff --git a/package.json b/package.json index f222bd9..2c47028 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,9 @@ "test": "echo \"Error: no test specified\" && exit 1", "build": "zx tools/build.mjs", "start": "zx tools/watch.mjs", - "update-origin": "zx tools/update-origin.mjs" - }, + "update-origin": "zx tools/update-origin.mjs", + "deploy:staging": "firebase use staging && firebase deploy --only hosting:staging" + }, "keywords": [], "author": "", "license": "ISC", diff --git a/tools/lib/common.mjs b/tools/lib/common.mjs index 1760265..14df66e 100644 --- a/tools/lib/common.mjs +++ b/tools/lib/common.mjs @@ -26,7 +26,7 @@ export async function buildADEV() { await within(async () => { cd(`${outDir}`); await $`yarn install`; - await $`yarn docs:build`; + await $`yarn bazel build //adev:build --fast_adev --local_ram_resources="HOST_RAM" --jobs=2`; }); }