Skip to content

Commit ce10bbc

Browse files
committed
massive documentation
1 parent 87b0842 commit ce10bbc

File tree

4 files changed

+200
-13
lines changed

4 files changed

+200
-13
lines changed

README.md

Lines changed: 197 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,39 @@
33
[![CircleCI](https://circleci.com/gh/angular-schule/angular-cli-ghpages.svg?style=svg)](https://circleci.com/gh/angular-schule/angular-cli-ghpages)
44
[![The MIT License](https://img.shields.io/badge/license-MIT-orange.svg?color=blue&style=flat-square)](http://opensource.org/licenses/MIT)
55

6+
Deploy your Angular app to GitHub pages directly from the Angular CLI! 🚀
7+
8+
69
<!--
710
TODO: cool screenshot with animated gif
811
<hr>
912
![Screenshot](screenshotgif)
1013
-->
1114

15+
**Table of contents:**
16+
17+
1. [📖 Changelog](#changelog)
18+
2. [⚠️ Prerequisites](#prerequisites)
19+
3. [🚀 Quick-start (local development)](#quickstart-local)
20+
4. [🚀 Continuous Delivery](#continuous-delivery)
21+
5. [📦 Options](#options)
22+
- [--base-href](#base-href)
23+
- [--configuration](#configuration)
24+
- [--repo](#repo)
25+
- [--message](#message)
26+
- [--branch](#branch)
27+
- [--name & --email](#name)
28+
- [--no-silent](#no-silent)
29+
- [--no-dotfiles](#no-dotfiles)
30+
- [--cname](#cname)
31+
- [--dry-run](#dry-run)
32+
6. [🏁 Next milestones](#milestones)
33+
7. [⁉️ FAQ](#faq)
34+
35+
36+
1237
<hr>
1338

14-
Deploy your Angular app to GitHub pages directly from the Angular CLI! 🚀
1539

1640

1741
## 📖 Changelog <a name="changelog"></a>
@@ -23,6 +47,7 @@ This is still possible.
2347
See the documentation at [README_standalone](docs/README_standalone).
2448

2549

50+
2651
## ⚠️ Prerequisites <a name="prerequisites"></a>
2752

2853
This command has the following prerequisites:
@@ -31,6 +56,7 @@ This command has the following prerequisites:
3156
- Angular project created via [Angular CLI](https://github.com/angular/angular-cli) v8.3.0-next.0 or greater (execute `ng update @angular/cli @angular/core --next=true` to upgrade your project if necessary)
3257

3358

59+
3460
## 🚀 Quick-start (local development) <a name="quickstart-local"></a>
3561

3662
This quickstart assumes that you are starting from scratch.
@@ -67,27 +93,34 @@ If you alreay have an existing Angular project on GitHub, skip step 1 and 2.
6793
4. Deploy your project to Github pages with all default settings.
6894
Your project will be automatically build in production mode.
6995

96+
```sh
97+
ng run deploy
98+
```
99+
100+
Which is the same as:
101+
70102
```sh
71103
ng run your-angular-project:deploy
72104
```
73105

74-
5. Your project should be available at `http(s)://<username>.github.io/<projectname>`.
106+
5. Your project should be available at `https://<username>.github.io/<repositoryname>`.
75107
Learn more about GitHub pages on the [official website](https://pages.github.com/).
76108

77109

110+
78111
## 🚀 Continuous Delivery <a name="continuous-delivery"></a>
79112

80113
If you run this command on a CI/CD environment, the deployment will most likely not work out of the box.
81-
For security reasons, those environments usually have read-only privileges.
114+
For security reasons, those environments usually have read-only privileges or you haven't set up git correctly.
82115
Therefore you should take a look at [Github tokens](https://help.github.com/articles/creating-an-access-token-for-command-line-use/).
83-
In short: a Github token replaces username and password and can be invalidated at any time.
116+
In short: a Github token replaces username and password and is a safer choice because a token can be revoked at any time.
84117

85118
All you need to do is set an environment variable called `GH_TOKEN` in our CI/CD environment.
86119
You should also set the URL to the repository using the `--repo` option.
87120
The URL must use the HTTPS scheme.
88121

89122
```sh
90-
ng run your-angular-project:deploy --repo=https://github.com/<username>/<repositoryname>.git --name="Your Git Username" [email protected]
123+
ng run deploy --repo=https://github.com/<username>/<repositoryname>.git --name="Your Git Username" [email protected]
91124
```
92125

93126
(replace `<username>` and `<repositoryname>` with your username from GitHub and the name of your repository)
@@ -96,11 +129,159 @@ ng run your-angular-project:deploy --repo=https://github.com/<username>/<reposit
96129
> You have to treat the GH_TOKEN as secure as a password!
97130
98131

99-
## Options
100132

101-
- `--base-href` - specifies the base url for the application being built. Same as `ng build --base-href=XXX`.
102-
- `--configuration`
103-
- TODO: document all the other options!
133+
## 📦 Options <a name="options"></a>
134+
135+
#### --base-href <a name="base-href"></a>
136+
* __optional__
137+
* Default: `undefined` (string)
138+
* Example:
139+
* `ng deploy` -- `<base href="/">` stays untouched in your `index.html`
140+
* `ng deploy --base-href=/the-repositoryname` -- `<base href="/the-repositoryname">` is added to your `index.html`
141+
142+
Specifies the base url for the application being built.
143+
Same as `ng build --base-href=XXX`
144+
145+
**ℹ️ Please read the next lines carefully, or you will get 404 errors in case of a wrong configuration!**
146+
147+
##### A) You don't want to use a custom domain
148+
149+
If you don't want to use an own domain, then your later URL of your hostet Angular project should look like this:
150+
`https://your-username.github.io/the-repositoryname`.
151+
In this case you have to adjust the `--base-href`:
152+
153+
```sh
154+
ng deploy --base-href=/the-repositoryname
155+
```
156+
157+
##### B) You want to use a custom domain
158+
159+
If you want to use your own domain, then you don't have to adjust `--base-href`.
160+
However, it is now necessary to set the `--cname` parameter!
161+
162+
```sh
163+
ng deploy --cname=example.org
164+
```
165+
166+
See the option [--cname](#cname) for more information!
167+
168+
#### --repo <a name="repo"></a>
169+
* __optional__
170+
* Default: url of the origin remote of the current dir (assumes a git repository)
171+
* Example: `ng deploy --repo=https://github.com/<username>/<repositoryname>.git`
172+
173+
By default, this command assumes that the current working directory is a git repository,
174+
and that you want to push changes to the `origin` remote.
175+
If instead your files are not in a git repository, or if you want to push to another repository,
176+
you can provide the repository URL in the `repo` option.
177+
178+
**Hint:**
179+
Set an environment variable with the name `GH_TOKEN` and it will be automatically added to the URL.
180+
(`https://github.com/<username>/<repositoryname>.git` is changed to `https://[email protected]/<username>/<repositoryname>.git`
181+
if there is an environment variable `GH_TOKEN` with the value `XXX`.
182+
Learn more about [Github tokens here](https://help.github.com/articles/creating-an-access-token-for-command-line-use/).)
183+
184+
185+
#### --configuration <a name="configuration"></a>
186+
* __optional__
187+
* Default: `production` (string)
188+
* Example:
189+
* `ng deploy` -- Angular project is build in production mode
190+
* `ng deploy --configuration=qs` -- Angular project is using the configuration `qs` (this configuration must exist in the `angular.json` file)
191+
192+
A named build target, as specified in the `configurations` section of `angular.json`.
193+
Each named target is accompanied by a configuration of option defaults for that target.
194+
Same as `ng build --configuration=XXX`.
195+
196+
197+
#### --message <a name="message"></a>
198+
* __optional__
199+
* Default: `Auto-generated commit` (string)
200+
* Example: `ng deploy --message="What could possibly go wrong?"`
201+
202+
The commit message, __must be wrapped in quotes__ if there are any spaces in the text.
203+
Some handy additional text is always added,
204+
if the environment variable `TRAVIS` exists (for Travis CI) or
205+
if the environment variable `CIRCLECI` exists (for Circle CI).
206+
207+
208+
#### --branch <a name="branch"></a>
209+
* __optional__
210+
* Default: `gh-pages` (string)
211+
* Example: `ng deploy --branch=master`
212+
213+
The name of the branch you'll be pushing to.
214+
The default uses GitHub's `gh-pages` branch,
215+
but this can be configured to push to any branch on any remote.
216+
You have to change this to `master` if you are pushing to an GitHub organisation page (instead of an GitHub user page).
217+
218+
219+
#### --name & --email <a name="name"></a>
220+
* __optional__
221+
* Default: value of `git config user.name` and `git config user.email`
222+
* Example: `ng deploy --name="Displayed Username" [email protected]`
223+
224+
If you are running the command in a repository without a `user.name` or `user.email` git config properties
225+
(or on a machine without these global config properties),
226+
you must provide user info before git allows you to commit.
227+
In this case provide **both** `name` and `email` string values to identify the committer.
228+
229+
230+
#### --no-silent <a name="no-silent"></a>
231+
* __optional__
232+
* Default: silent `true` (boolean)
233+
* Example:
234+
* `ng deploy` -- Logging is in silent mode by default.
235+
* `ng deploy --no-silent` -- Logging shows extended information.
236+
237+
Logging is in silent mode by default.
238+
In silent mode log messages are suppressed and error messages are sanitized.
239+
240+
The `--no-silent` option enables extended console logging.
241+
Keep this untouched if the repository URL or other information passed to git commands is sensitive!
242+
243+
> WARNING: This option should kept like it is if the repository URL or other information passed to git commands is sensitive and should not be logged (== you have a public build server and you are using the `GH_TOKEN` feature).
244+
> By default the silent mode is enabled to avoid sensitive data exposure.
245+
246+
247+
#### --no-dotfiles <a name="no-dotfiles"></a>
248+
* __optional__
249+
* Default: dotfiles `true` (boolean)
250+
* Example:
251+
* `ng deploy` -- Dotfiles are included by default.
252+
* `ng deploy --no-dotfiles` -- Dotfiles are ignored.
253+
254+
The command includes dotfiles by default (e.g `.htaccess` will be committed)
255+
With `--no-dotfiles` files starting with `.` are ignored.
256+
257+
**Hint:**
258+
This is super usefull if you want to publish a `.nojekyll` file.
259+
Create such a file in the root of your pages repo to bypass the Jekyll static site generator on Github Pages.
260+
Static content is still delivered – even without Jekyll.
261+
This should only be necessary if your site uses files or directories that start with **_underscores** since Jekyll considers these to be special resources and does not copy them to the final site.
262+
→ Or just don't use underscores!
263+
264+
265+
#### --cname <a name="cname"></a>
266+
* __optional__
267+
* Default: `undefined` (string) – No CNAME file is generated
268+
* Example:
269+
* `ng deploy --cname=example.com`
270+
271+
A CNAME file will be created enabling you to use a custom domain.
272+
[More information on Github Pages using a custom domain](https://help.github.com/articles/using-a-custom-domain-with-github-pages/).
273+
274+
275+
#### --dry-run <a name="dry-run"></a>
276+
* __optional__
277+
* Default: `false` (boolean)
278+
* Example:
279+
* `ng deploy` -- Normal behaviour: Changes are applied.
280+
* `ng deploy --dry-run` -- No changes are applied at all.
281+
282+
Run through without making any changes.
283+
This can be very usefull, because it outputs what would happend without doing anything.
284+
104285

105286

106287
## 🏁 Next milestones <a name="milestones"></a>
@@ -110,16 +291,19 @@ But we are looking forward to the following features:
110291

111292
* an interactive command-line prompt that guides you through the available options
112293
* a configuration file (`angular-cli-ghpages.json`) to avoid all these command-line cmd options
294+
* your feature that's not on the list yet?
113295

114296
We look forward to any help. PRs are welcome! 😃
115297

298+
299+
116300
## ⁉️ FAQ <a name="faq"></a>
117301

118302
Before posting any issue, [please read the FAQ first](https://github.com/angular-schule/angular-cli-ghpages/wiki/FAQ).
119303
See the contributors documentation at [README_contributors](docs/README_contributors) if you want to debug and test this project.
120304

121305

122-
## License
306+
## License <a name="license"></a>
123307
Code released under the [MIT license](LICENSE).
124308

125309
<hr>
@@ -128,5 +312,8 @@ Code released under the [MIT license](LICENSE).
128312

129313
### &copy; 2019 https://angular.schule
130314

315+
This project is made on top of [tschaub/gh-pages](https://github.com/tschaub/gh-pages).
316+
Thank you very much for this great foundation!
317+
131318
[npm-url]: https://www.npmjs.com/package/angular-cli-ghpages
132319
[npm-image]: https://badge.fury.io/js/angular-cli-ghpages.svg

docs/README_standalone.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ For your convenience, the command will recognize the [environment variable](http
7878
In example, the following command runs [on our Travis-CI](https://travis-ci.org/angular-buch/book-monkey2):
7979

8080
```bash
81-
npx angular-cli-ghpages --repo=https://[email protected]/organisation/your-repo.git --name="Displayed Username" [email protected]
81+
npx angular-cli-ghpages --repo=https://[email protected]/<username>/<repositoryname>.git --name="Displayed Username" [email protected]
8282
```
8383
> You have to treat the GH_TOKEN as secure as a password!
8484

@@ -101,7 +101,7 @@ Output the version number. Please provide the version number on any bug report!
101101
#### --repo <a name="repo"></a>
102102
* __optional__
103103
* Default: url of the origin remote of the current dir (assumes a git repository)
104-
* Example: `npx angular-cli-ghpages --repo=https://[email protected]/organisation/your-repo.git`
104+
* Example: `npx angular-cli-ghpages --repo=https://[email protected]/<username>/<repositoryname>.git`
105105

106106
By default, __gh-pages__ assumes that the current working directory is a git repository,
107107
and that you want to push changes to the `origin` remote.

src/angular-cli-ghpages

100644100755
File mode changed.

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"ngh": "angular-cli-ghpages"
99
},
1010
"scripts": {
11-
"build": "rm -rf dist && json2ts deploy/schema.json > deploy/schema.d.ts && tsc && cp README.md builders.json collection.json package.json angular-cli-ghpages dist && cp deploy/schema.json dist/deploy",
11+
"build": "rm -rf dist && json2ts deploy/schema.json > deploy/schema.d.ts && tsc && cp ../README.md builders.json collection.json package.json angular-cli-ghpages dist && cp deploy/schema.json dist/deploy",
1212
"test": "jest"
1313
},
1414
"schematics": "./collection.json",

0 commit comments

Comments
 (0)