Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 667ff87

Browse files
committed
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.
1 parent b481a16 commit 667ff87

File tree

5 files changed

+21
-27
lines changed

5 files changed

+21
-27
lines changed

.circleci/config.yml

+14-4
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,20 @@ jobs:
385385
- custom_attach_workspace
386386
- init_environment
387387
- skip_unless_stable_branch
388-
# Install dependencies for Firebase functions to prevent parsing errors during deployment
389-
# See https://github.com/angular/angular.js/pull/16453
390-
- run: yarn --cwd scripts/docs.angularjs.org-firebase/functions --ignore-engines
391-
- run: yarn firebase deploy --message "Commit:\ $CI_COMMIT" --non-interactive --only hosting --project "docs-angularjs-org-9p2" --token "$FIREBASE_TOKEN"
388+
# Install dependencies for Firebase functions to prevent parsing errors during deployment.
389+
# See https://github.com/angular/angular.js/pull/16453.
390+
- run:
391+
name: Install dependencies in `scripts/docs.angularjs.org-firebase/functions/`.
392+
working_directory: scripts/docs.angularjs.org-firebase/functions
393+
command: yarn install --frozen-lockfile --ignore-engines --non-interactive
394+
- run:
395+
name: Deploy to Firebase from `scripts/docs.angularjs.org-firebase/`.
396+
working_directory: scripts/docs.angularjs.org-firebase
397+
command: |
398+
# Do not use `yarn firebase` as that causes the Firebase CLI to look for `firebase.json`
399+
# in the root directory, even if run from inside `scripts/docs.angularjs.org-firebase/`.
400+
firebase=$(yarn bin)/firebase
401+
$firebase deploy --message "Commit:\ $CI_COMMIT" --non-interactive --only hosting --project "docs-angularjs-org-9p2" --token "$FIREBASE_TOKEN"
392402
393403
workflows:
394404
version: 2

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@ npm-debug.log
2525
scripts/code.angularjs.org-firebase/deploy
2626
scripts/docs.angularjs.org-firebase/deploy
2727
scripts/docs.angularjs.org-firebase/functions/content
28-
/firebase.json

Gruntfile.js

-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@ module.exports = function(grunt) {
518518
]);
519519
grunt.registerTask('prepareDeploy', [
520520
'copy:deployFirebaseCode',
521-
'firebaseDocsJsonForCI',
522521
'copy:deployFirebaseDocs'
523522
]);
524523
grunt.registerTask('default', ['package']);

lib/grunt/utils.js

+2-17
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@ var spawn = require('npm-run').spawn;
77

88
var CSP_CSS_HEADER = '/* Include this file in your html if you are using the CSP mode. */\n\n';
99

10-
const codeScriptFolder = 'scripts/code.angularjs.org-firebase';
11-
const docsScriptFolder = 'scripts/docs.angularjs.org-firebase';
12-
1310
module.exports = {
1411

15-
codeScriptFolder,
12+
codeScriptFolder: 'scripts/code.angularjs.org-firebase',
1613

17-
docsScriptFolder,
14+
docsScriptFolder: 'scripts/docs.angularjs.org-firebase',
1815

1916
startKarma: function(config, singleRun, done) {
2017
var browsers = grunt.option('browsers');
@@ -306,18 +303,6 @@ module.exports = {
306303
}
307304
next();
308305
};
309-
},
310-
311-
// Our Firebase projects are in subfolders, but the firebase tool expects them in the root,
312-
// so we need to modify the upload folder path and copy the file into the root
313-
firebaseDocsJsonForCI: function() {
314-
var fileName = docsScriptFolder + '/firebase.json';
315-
var json = grunt.file.readJSON(fileName);
316-
317-
(json.hosting || (json.hosting = {})).public = docsScriptFolder + '/deploy';
318-
(json.functions || (json.functions = {})).source = docsScriptFolder + '/functions';
319-
320-
grunt.file.write('firebase.json', JSON.stringify(json));
321306
}
322307

323308
};

scripts/docs.angularjs.org-firebase/readme.firebase.docs.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ See `/scripts/code.angularjs.org-firebase/readme.firebase.code.md` for the Fireb
77

88
# Continuous integration
99

10-
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`).
11-
The `firebaseDocsJsonForCI` task modifies the paths in the `firebase.json` and copies it to the repository root.
10+
The docs are deployed to Google Firebase hosting and functions automatically via CI.
1211

1312
See `.circleci/config.yml` for the complete deployment config and build steps.
1413

1514
# Serving locally:
1615

16+
- Run `cd scripts/docs.angularjs.org-firebase`.
17+
This changes the current working directory.
18+
1719
- Run `yarn grunt package`.
1820
This builds the files that will be deployed.
1921

2022
- Run `yarn grunt prepareDeploy`.
2123
This copies docs content files into `./deploy` and the partials for Search Engine AJAX Crawling into `./functions/content`.
22-
It also moves the `firebase.json` file to the root folder, where the firebase-cli expects it.
2324

24-
- Run `firebase serve --only functions,hosting`
25+
- Run `$(yarn bin)/firebase emulators:start` (or `..\..\node_modules\.bin\firebase emulators:start` on Windows).
2526
Creates a server at http://localhost:5000 that serves from `./deploy` and uses the local function.

0 commit comments

Comments
 (0)