TruCol / Self-host-GitLab-CI-for-GitHub

Installs your own GitLab CI and runs it on all your GitHub repos, in a single command.
GNU Affero General Public License v3.0
4 stars 3 forks source link

Reduce GitHub bandwidth by cloning build status repo only once per run, and pushing only once per run. #91

Closed a-t-0 closed 2 years ago

a-t-0 commented 2 years ago

Only download the GitHub build status repository once, and check if it exists before downloading. Include push boolean into run_ci_on_github_repo method to indicate whether it should push once it is done (e.g. when it is only ran manually on a single repo), or if it should wait, such that a single push is done after:

    echo "github_repositories=${github_repositories[@]}"
    for github_repository in "${github_repositories[@]}"; do
        echo "$github_repository"
        run_ci_on_github_repo "$github_organisation_or_username" "$github_repository" "$github_organisation_or_username"
    done

To do this, move the code:

    # Verify ssh-access
    #has_access="$(check_ssh_access_to_repo "$github_username" "$GITHUB_STATUS_WEBSITE_GLOBAL")"

    # 8. Clone the GitHub build statusses repository.
    printf " download_and_overwrite_repository_using_ssh"
    download_and_overwrite_repository_using_ssh "$GITHUB_USERNAME_GLOBAL" "$GITHUB_STATUS_WEBSITE_GLOBAL" "$MIRROR_LOCATION/GitHub/$GITHUB_STATUS_WEBSITE_GLOBAL"
    sleep 2

    # 9. Verify the Build status repository is cloned.
    manual_assert_dir_exists "$MIRROR_LOCATION/GitHub/$GITHUB_STATUS_WEBSITE_GLOBAL"
    # 10. Copy the GitLab CI Build status icon to the build status repository.
    # Create a folder of the repository on which a CI has been ran, inside the GitHub build status website repository, if it does not exist yet
    # Also add a folder for the branch(es) of that GitLab CI repository, in that respective folder.

A bit up.

Then do the same for the run_ci_on_commit.sh file, and only push the results after all the repositories are evaluated.