-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(deploy:github-pages): support usage of gh-token for deployment f…
…rom external env (#3121) In order to being able to push to github from CI (Travis for example), we should be able to provide a token to the cli, as `--gh-token=XYZ`. This modification allow to use this token in the destination url. This also allow user to push to another github repository if it uses a different `--gh-username` from the one used for the checkout.
- Loading branch information
1 parent
da1c197
commit 3c82b77
Showing
3 changed files
with
150 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,44 @@ describe('Acceptance: ng github-pages:deploy', function() { | |
return ng(['github-pages:deploy', '--skip-build']); | ||
}); | ||
|
||
it('should deploy with token and username', function () { | ||
let token = 'token', | ||
username = 'bar'; | ||
|
||
execStub.addExecSuccess('git status --porcelain') | ||
.addExecSuccess('git rev-parse --abbrev-ref HEAD', initialBranch) | ||
.addExecSuccess('git remote -v', remote) | ||
.addExecSuccess(`git checkout ${ghPagesBranch}`) | ||
.addExecSuccess('git ls-files') | ||
.addExecSuccess('git rm -r ') | ||
.addExecSuccess('git add .') | ||
.addExecSuccess(`git commit -m "${message}"`) | ||
.addExecSuccess(`git checkout ${initialBranch}`) | ||
.addExecSuccess(`git push https://${token}@github.com/${username}/${project}.git ${ghPagesBranch}:${ghPagesBranch}`) | ||
.addExecSuccess('git remote -v', remote); | ||
|
||
return ng(['github-pages:deploy', '--skip-build', `--gh-token=${token}`, `--gh-username=${username}`]); | ||
}) | ||
|
||
it('should deploy with token only', function () { | ||
let token = 'token'; | ||
|
||
execStub.addExecSuccess('git status --porcelain') | ||
.addExecSuccess('git rev-parse --abbrev-ref HEAD', initialBranch) | ||
.addExecSuccess('git remote -v', remote) | ||
.addExecSuccess(`git checkout ${ghPagesBranch}`) | ||
.addExecSuccess('git ls-files') | ||
.addExecSuccess('git rm -r ') | ||
.addExecSuccess('git add .') | ||
.addExecSuccess(`git commit -m "${message}"`) | ||
.addExecSuccess(`git checkout ${initialBranch}`) | ||
.addExecSuccess('git remote -v', remote) | ||
.addExecSuccess(`git push https://${token}@github.com/username/${project}.git ${ghPagesBranch}:${ghPagesBranch}`) | ||
.addExecSuccess('git remote -v', remote); | ||
|
||
return ng(['github-pages:deploy', '--skip-build', `--gh-token=${token}`]); | ||
}); | ||
|
||
it('should deploy with changed defaults', function() { | ||
let userPageBranch = 'master', | ||
message = 'not new gh-pages version'; | ||
|
@@ -126,14 +164,14 @@ describe('Acceptance: ng github-pages:deploy', function() { | |
.addExecSuccess('git rev-parse --abbrev-ref HEAD', initialBranch) | ||
.addExecSuccess('git remote -v', noRemote) | ||
.addExecSuccess(`git remote add origin [email protected]:${username}/${project}.git`) | ||
.addExecSuccess(`git push -u origin ${initialBranch}`) | ||
.addExecSuccess(`git push -u https://${token}@github.com/${username}/${project}.git ${initialBranch}`) | ||
.addExecSuccess(`git checkout ${ghPagesBranch}`) | ||
.addExecSuccess('git ls-files') | ||
.addExecSuccess('git rm -r ') | ||
.addExecSuccess('git add .') | ||
.addExecSuccess(`git commit -m "${message}"`) | ||
.addExecSuccess(`git checkout ${initialBranch}`) | ||
.addExecSuccess(`git push origin ${ghPagesBranch}:${ghPagesBranch}`) | ||
.addExecSuccess(`git push https://${token}@github.com/${username}/${project}.git ${ghPagesBranch}:${ghPagesBranch}`) | ||
.addExecSuccess('git remote -v', remote); | ||
|
||
var httpsStub = sinon.stub(https, 'request', httpsRequestStubFunc); | ||
|