Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ deploy:

While this plugin can parse authentication token from the config, only use this method if you are sure the config will not be committed, including to a private repo. A more secure approach is to add it to the CI as an environment variable, then simply add the name of the environment variable to this plugin's config (e.g. `$GITHUB_TOKEN`).

Token format can be pure token like `this_is_token_string` or can be linke `username:password`` format.

Additional guides:

- Create a GitHub Personal Access Token. [[Link]](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line)
Expand Down
10 changes: 8 additions & 2 deletions lib/parse_config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const rRepoURL = /^(?:(git|https?|git\+https|git\+ssh):\/\/)?(?:[^@]+@)?([^\/]+?)[\/:](.+?)\.git$/; // eslint-disable-line no-useless-escape
const rUserPassword = /([^:]+)(?::)(.+)/; // eslint-disable-line no-useless-escape
const rGithubPage = /\.github\.(io|com)$/;
const { URL } = require('url');

Expand Down Expand Up @@ -30,11 +31,16 @@ function parseObjRepo(repo) {
} else {
userToken = configToken;
}
repoUrl.username = userToken;
if (rUserPassword.test(userToken)) {
const match = userToken.match(rUserPassword);
repoUrl.username = match[1];
repoUrl.password = match[2];
} else {
repoUrl.username = userToken;
}
url = repoUrl.href;
}
}

return {
url: url,
branch: branch || 'master'
Expand Down