parent
6033c4e16e
commit
8330f93a3d
|
@ -43,6 +43,7 @@ This will a spin up a docker container running infinite which will try to mirror
|
|||
### Parameters
|
||||
|
||||
- `GITHUB_USERNAME` name of user or organization which public repos should be mirrored
|
||||
- `GITHUB_TOKEN` [GitHub personal access token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) (optional)
|
||||
- `GITEA_URL` url of your gitea server
|
||||
- `GITEA_TOKEN` token for your gitea user
|
||||
|
||||
|
|
10
src/index.js
10
src/index.js
|
@ -1,8 +1,11 @@
|
|||
const octokit = require('@octokit/rest')();
|
||||
const {Octokit} = require('@octokit/rest');
|
||||
const request = require('superagent');
|
||||
|
||||
|
||||
async function getGithubRepositories(username) {
|
||||
async function getGithubRepositories(username, token) {
|
||||
const octokit = new Octokit({
|
||||
auth: token || null,
|
||||
});
|
||||
return octokit.paginate('GET /users/:username/repos', { username: username })
|
||||
.then(repositories => toRepositoryList(repositories));
|
||||
}
|
||||
|
@ -66,6 +69,7 @@ async function main() {
|
|||
console.error('No GITHUB_USERNAME specified, please specify! Exiting..');
|
||||
return;
|
||||
}
|
||||
const githubToken = process.env.GITHUB_TOKEN;
|
||||
const giteaUrl = process.env.GITEA_URL;
|
||||
if (!giteaUrl) {
|
||||
console.error('No GITEA_URL specified, please specify! Exiting..');
|
||||
|
@ -79,7 +83,7 @@ async function main() {
|
|||
}
|
||||
|
||||
|
||||
const githubRepositories = await getGithubRepositories(githubUsername);
|
||||
const githubRepositories = await getGithubRepositories(githubUsername, githubToken);
|
||||
console.log(`Found ${githubRepositories.length} repositories on github`);
|
||||
|
||||
const gitea = {
|
||||
|
|
Loading…
Reference in New Issue