chore(ci): deploy to docs.angularjs.org from within the corresponding directory

Previously, in order to deploy to Firebase from
`scripts/docs.angularjs.org-firebase/`, we had to copy the
`firebase.json` file to the repository root and adjust the contained
paths accordingly.

By running the `firebase` CLI directly (instead of via `yarn`), we are
able to deploy from `docs.angularjs.org-firebase/` directly. This
simplifies the deployment (and local testing) process and paves the way
for also deploying from `code.angularjs.org-firebase/` in a subsequent
commit.
This commit is contained in:
George Kalpakas
2021-02-05 21:00:44 +02:00
parent b481a16576
commit 667ff87ab5
5 changed files with 21 additions and 27 deletions
+14 -4
View File
@@ -385,10 +385,20 @@ jobs:
- custom_attach_workspace
- init_environment
- skip_unless_stable_branch
# Install dependencies for Firebase functions to prevent parsing errors during deployment
# See https://github.com/angular/angular.js/pull/16453
- run: yarn --cwd scripts/docs.angularjs.org-firebase/functions --ignore-engines
- run: yarn firebase deploy --message "Commit:\ $CI_COMMIT" --non-interactive --only hosting --project "docs-angularjs-org-9p2" --token "$FIREBASE_TOKEN"
# Install dependencies for Firebase functions to prevent parsing errors during deployment.
# See https://github.com/angular/angular.js/pull/16453.
- run:
name: Install dependencies in `scripts/docs.angularjs.org-firebase/functions/`.
working_directory: scripts/docs.angularjs.org-firebase/functions
command: yarn install --frozen-lockfile --ignore-engines --non-interactive
- run:
name: Deploy to Firebase from `scripts/docs.angularjs.org-firebase/`.
working_directory: scripts/docs.angularjs.org-firebase
command: |
# Do not use `yarn firebase` as that causes the Firebase CLI to look for `firebase.json`
# in the root directory, even if run from inside `scripts/docs.angularjs.org-firebase/`.
firebase=$(yarn bin)/firebase
$firebase deploy --message "Commit:\ $CI_COMMIT" --non-interactive --only hosting --project "docs-angularjs-org-9p2" --token "$FIREBASE_TOKEN"
workflows:
version: 2
-1
View File
@@ -25,4 +25,3 @@ npm-debug.log
scripts/code.angularjs.org-firebase/deploy
scripts/docs.angularjs.org-firebase/deploy
scripts/docs.angularjs.org-firebase/functions/content
/firebase.json
-1
View File
@@ -518,7 +518,6 @@ module.exports = function(grunt) {
]);
grunt.registerTask('prepareDeploy', [
'copy:deployFirebaseCode',
'firebaseDocsJsonForCI',
'copy:deployFirebaseDocs'
]);
grunt.registerTask('default', ['package']);
+2 -17
View File
@@ -7,14 +7,11 @@ var spawn = require('npm-run').spawn;
var CSP_CSS_HEADER = '/* Include this file in your html if you are using the CSP mode. */\n\n';
const codeScriptFolder = 'scripts/code.angularjs.org-firebase';
const docsScriptFolder = 'scripts/docs.angularjs.org-firebase';
module.exports = {
codeScriptFolder,
codeScriptFolder: 'scripts/code.angularjs.org-firebase',
docsScriptFolder,
docsScriptFolder: 'scripts/docs.angularjs.org-firebase',
startKarma: function(config, singleRun, done) {
var browsers = grunt.option('browsers');
@@ -306,18 +303,6 @@ module.exports = {
}
next();
};
},
// Our Firebase projects are in subfolders, but the firebase tool expects them in the root,
// so we need to modify the upload folder path and copy the file into the root
firebaseDocsJsonForCI: function() {
var fileName = docsScriptFolder + '/firebase.json';
var json = grunt.file.readJSON(fileName);
(json.hosting || (json.hosting = {})).public = docsScriptFolder + '/deploy';
(json.functions || (json.functions = {})).source = docsScriptFolder + '/functions';
grunt.file.write('firebase.json', JSON.stringify(json));
}
};
@@ -7,19 +7,20 @@ See `/scripts/code.angularjs.org-firebase/readme.firebase.code.md` for the Fireb
# Continuous integration
The docs are deployed to Google Firebase hosting via a CI deployment config, which expects `firebase.json` to be in the repository root, which is done by a Grunt task (`firebaseDocsJsonForCI` which is included in `prepareDeploy`).
The `firebaseDocsJsonForCI` task modifies the paths in the `firebase.json` and copies it to the repository root.
The docs are deployed to Google Firebase hosting and functions automatically via CI.
See `.circleci/config.yml` for the complete deployment config and build steps.
# Serving locally:
- Run `cd scripts/docs.angularjs.org-firebase`.
This changes the current working directory.
- Run `yarn grunt package`.
This builds the files that will be deployed.
- Run `yarn grunt prepareDeploy`.
This copies docs content files into `./deploy` and the partials for Search Engine AJAX Crawling into `./functions/content`.
It also moves the `firebase.json` file to the root folder, where the firebase-cli expects it.
- Run `firebase serve --only functions,hosting`
- Run `$(yarn bin)/firebase emulators:start` (or `..\..\node_modules\.bin\firebase emulators:start` on Windows).
Creates a server at http://localhost:5000 that serves from `./deploy` and uses the local function.