angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.77k stars 11.98k forks source link

Deploying Github Page #720

Closed piotrromanowski closed 8 years ago

piotrromanowski commented 8 years ago

When you run the command ng github-pages:deploy and the project successfully creates a branch on your github account, you receive message that says Deployed! Visit https://${userName}.github.io/${projectName}/ and Github pages might take a few minutes to show the deployed site. however the site is actually never deployed. It just creates the "gh-pages" branch on that repository.

filipesilva commented 8 years ago

Heya,

I think this is related to (but perhaps not fully caused by) you using a user page instead of a project page.

Basically, when you do a user page, the generated content must be in the master branch, and to be honest that case isn't well covered yet.

Can I ask you to try again with a different project name?

Meanwhile I'll work on both enabling and documenting the user page scenario.

EmmanuelTsouris commented 8 years ago

Not sure if this is related, but I was able to successfully deploy to github pages using ng github-pages:deploy --message "Optional commit message"

After deployment, I saw a blank page with a bunch of errors in the console. I figured it was related to the base href, so I used the dynamic method outlined in the docs.

That fixed my blank page. https://emmanueltsouris.github.io/ng2-MediaBrowser/

EmmanuelTsouris commented 8 years ago

I seem to recall that there was also an anomoly with the link and the base href when I first published to github pages. Somehow there was an extra dash in the name.

So my project ng2-MediaBrowser had ng2-media-browser in the base href (was also shown to me by the cli output). When I navigated to the url, I saw a 404. When I noticed the extra dash, I looked at my repo settings, saw that the correct page url was actually .../ng2-MediaBrowser and not .../ng2-Media-Browser

Not sure where that extra dash came from, if it was my typing or a bug in the cli. I'll run it again with a similar project name when I have a chance.

piotrromanowski commented 8 years ago

@EmmanuelTsouris Thanks for the suggestions I'll have another look! I'll also checkout your project to compare to see what I possibly did wrong

filipesilva commented 8 years ago

@EmmanuelTsouris I'm glad to hear the feature worked for you! Not too sure of the extra dash issue, can you tell me your results with the new project?

@piotrromanowski I put up a PR that should allow you to easily push a user/org page (instead of a project page), you can find it here: https://github.com/angular/angular-cli/pull/772

It also fixes a current bug that completely breaks the deploy process.

EmmanuelTsouris commented 8 years ago

@filipesilva I tested it again with a new project, this time I hadn't created the github project beforehand.

I created a project ng new ng2-TestProject.

I did a commit (no remote origin set yet), and then tried to do a github-pages deploy

Now I'm having issues with the token, I created a token initially with just the public repo access, but was getting access denied messages, so tried a few different extra perms, none seemed to work.

When I did this all before with my other project, I had created the project using the same name as the folder and added it as origin before doing the github-pages deploy. Which may be why it worked, and why the base href had the dash (but my project folder didn't have a dash).

Hope this helps

filipesilva commented 8 years ago

@EmmanuelTsouris hm, odd that it fails with a token issue after the project is created on github... The token is solely used to create the github repo, so I wouldn't expect it to be used in any way after that.

Can you copy paste the error you got? If it's something like there are no changes, deploy aborted that it is actually the issue my PR is meant to fix.

EmmanuelTsouris commented 8 years ago

@filipesilva here's the error, it was a classic missing key in git:

Command failed: /bin/sh -c git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

There was a permissions error during git file operations, please close any open project files/folders and try again.
You might also need to return to the master branch manually.

I [stepped through my git config](https://help.github.com/articles/error-permission-denied-publickey/ to). ssh-add -l showed no identities. So my github generated identity wasn't being used. I fixed the identity/key issue, and then retried the github-pages deploy. The project published successfully as https://emmanueltsouris.github.io/ng2-test-project/

Not an issue with angular-cli, just git being flakey with using the Github Mac generated github_rsa

filipesilva commented 8 years ago

@EmmanuelTsouris awesome, glad to hear it now works well! I like the message on the page as well :D

priyeshn commented 7 years ago

Getting "Failed to create GitHub repo. Error: 401 Unauthorized" when tries to deploys angular 2 app to my organization guthub page . Asking for a token and fails with 401

ng github-pages:deploy

? Please enter GitHub token you just created (used only once to create the repo): ? and your GitHub user name: Failed to create GitHub repo. Error: 401 Unauthorized

priyeshn commented 7 years ago

@filipesilva Please help . Getting "Failed to create GitHub repo. Error: 401 Unauthorized" when tries to deploys angular 2 app to my organization guthub page . Asking for a token and fails with 401

ng github-pages:deploy

? Please enter GitHub token you just created (used only once to create the repo): ? and your GitHub user name: Failed to create GitHub repo. Error: 401 Unauthorized

EmmanuelTsouris commented 7 years ago

@priyeshn sounds like a GitHub command line issue. Have you looked at https://help.github.com/articles/creating-an-access-token-for-command-line-use/

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.