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

Add ssh key to GitHub if not done yet.

Closed this issue · 5 comments

a-t-0 commented

On a clean install of Ubuntu, running:

./install_gitlab.sh -s -r -hu a-t-0 -le somegitlab@email.com -lp -hp

yields:

4. Verifying the gitlab-ci-build-statuses and sponsor_example repositories exist in your GitHub account.GITHUB_PERSONAL_ACCESS_TOKEN_GLOBAL=

GITHUB_PERSONAL_ACCESS_TOKEN_GLOBAL=

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
The dir: src/mirrors/GitHub/gitlab-ci-build-statuses does not exist, even though one would expect it does.
  • Tell the user to add the ssh key to GitHub, or do this for the user.
a-t-0 commented

	elif [ "$found_error_in_ssh_command" == "FOUND" ]; then
		# Two tries is enough to determine the device does not have ssh-access.
		if [ "$is_retry" == "YES" ]; then
			echo "NOTFOUND"
		else
			create_and_activate_local_github_ssh_deploy_key 
			# Perform recursive call to run function one more time.
			echo $(check_quick_ssh_access_to_repo "$github_username" "$github_repository" "YES")
		fi

	elif [ "$found_permission_lack_in_ssh_command" == "FOUND" ]; then
		# Two tries is enough to determine the device does not have ssh-access.
		create_and_activate_local_github_ssh_deploy_key
		read -p "Set ssh key"
		# Perform recursive call to run function one more time.
		echo $(check_quick_ssh_access_to_repo "$github_username" "$github_repository" "YES")
		read -p "checked has access again."
	fi
a-t-0 commented

Output:

6. Ensuring you have ssh push access to the gitlab-ci-build-statuses repository with your ssh-deploy key.HIIIII has_quick_ssh_access_to_github=NOTFOUND
Identity added: /home/name/.ssh/some_github_deploy_key (example@example.com)

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

yes: standard output: Broken pipe

HIIIII has_quick_ssh_access_to_github=FOUND
STOP ensured_quick_ssh_access_to_github=FOUND
Agent pid 48156
Reading package lists...
Building dependency tree...
Reading state information...
wget is already the newest version (1.21.3-1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
Setting and getting GitHub ssh-deploy key (NOT TOKEN).
The ssh deploy key is:=ssh-some key example@example.com
Loading geckodriver
Loading took too much time!
Please enter the two factor authentication you just received:Page is ready!
Page is ready!
Page is ready!
Page is ready!
Done adding the ssh deploy key from your machine to:gitlab-ci-build-statuses. Waiting 10 seconds and then the browser.
Done setting GitHub deployment token repo:gitlab-ci-build-statuses.
Done.
ENSURED_QUICK_SSH_ACCESS

  • Ensure the pipe to the user does not get broken, such that the user sees the 2FA code prompt.
  • Make sure the browsercontroller browser history is cleared upon entry and exit.
a-t-0 commented

5. Setting and Getting the GitHub personal access token if it does not yet exist.  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5607  100  5607    0     0  15755      0 --:--:-- --:--:-- --:--:-- 15794
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5607  100  5607    0     0  18178      0 --:--:-- --:--:-- --:--:-- 18204
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   279  100   279    0     0   2078      0 --:--:-- --:--:-- --:--:--  2066
jq: error (at <stdin>:1): Cannot index string with string "sha"
Error, the commit sha: is not of correct length


 Now using a browser controller repository to create a GitHub personal access token and store it localy.

.

  • Ensure the check if github personal access token works, before adding a new one.
a-t-0 commented

Third error:

pac=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
File exists,new_line=GITHUB_PERSONAL_ACCESS_TOKEN_GLOBAL=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
Hi, I'm done creating the GitHub personal access token to set the GitHub commit build status.
Done.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    90  100    90    0     0    294      0 --:--:-- --:--:-- --:--:--   295
curl: (3) URL using bad/illegal format or missing URL
jq: error (at <stdin>:1): Cannot index string with string "url"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    90  100    90    0     0    339      0 --:--:-- --:--:-- --:--:--   338
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   217  100    90  100   127    334    471 --:--:-- --:--:-- --:--:--   806
Error, was not able to use the GitHub personal access token (I):
NOTFOUND
Error, was not able to use the GitHub personal access token (II):
Error, the GitHub commit status was not succesfully set to:pending


  • Resolve error.
a-t-0 commented

Done.