Gitlab/GitHub: Difference between revisions
(Created page with "== Gitlab project == [https://gitlab.com/qemu-project gitlab project] === Instructions to create a push mirror to GitHub == #Create the new repository on https://github.com/q...") |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
[https://gitlab.com/qemu-project gitlab project] | [https://gitlab.com/qemu-project gitlab project] | ||
=== | === Deploying from Gitlab CI/CD to qemu.org === | ||
There is a user qemu-deploy on qemu.org for CI/CD jobs that need to deploy to the qemu.org web root. The private key is stored into a file variable SSH_PRIVATE_KEY_FILE of the [https://gitlab.com/qemu-project/qemu qemu] and [https://gitlab.com/qemu-project/qemu-web qemu-web] GitLab repositories. If you need it for any reason (you shouldn't), please ask the [[AdminContacts|owners for the GitLab organization]]. | |||
If you need to use the key, also please coordinate with qemu.org owners to have a "temporary" private key added to <tt>~qemu-deploy/.ssh/authorized_keys</tt> first (note: the .ssh/authorized_keys file is made immutable with <tt>chattr +i</tt>). Only switch to the existing private key when everything works. This ensures for example that the private key is not leaked into job logs! | |||
=== Creating a new repository === | |||
To setup a mirror from an upstream repository to Gitlab: | |||
#Create the new repository on https://gitlab.com/qemu-project | |||
#Click Settings->Repository | |||
#Expand "Mirroring repositories" | |||
#When creating the Pull mirroring rule, choose "Keep divergent refs" | |||
To mirror the repository to GitHub, you will need admin access on Gitlab and GitHub. | |||
#Create the new repository on https://github.com/qemu | #Create the new repository on https://github.com/qemu | ||
#Do not close GitHub, open the source repo https://gitlab.com/qemu-project/projectname | #Do not close GitHub, open the source repo https://gitlab.com/qemu-project/projectname | ||
#Click Setting-> | #Click Setting->Repository | ||
#Expand "Mirroring repositories" | #Expand "Mirroring repositories" | ||
#Set "Git repository URL" to ssh://git@github.com/qemu/projectname.git | #Set "Git repository URL" to ssh://git@github.com/qemu/projectname.git | ||
Line 22: | Line 36: | ||
#On Gitlab click the retry icon | #On Gitlab click the retry icon | ||
To mirror the GitLab repository from qemu.org, you will need root access on qemu.org: | |||
<pre> | |||
REPONAME=repo.git | |||
cd /srv/git | |||
git init --bare $REPONAME | |||
mv hooks/post-update.sample hooks/post-update | |||
git remote add --mirror=fetch gitlab https://gitlab.com/qemu-project/$REPONAME | |||
git config remote.gitlab.mirror true | |||
echo $REPONAME >> ~gituser/repos | |||
</pre> | |||
== GitHub project == | == GitHub project == | ||
[https://github.com/qemu github organization] | [https://github.com/qemu github organization] |
Latest revision as of 17:57, 19 January 2021
Gitlab project
Deploying from Gitlab CI/CD to qemu.org
There is a user qemu-deploy on qemu.org for CI/CD jobs that need to deploy to the qemu.org web root. The private key is stored into a file variable SSH_PRIVATE_KEY_FILE of the qemu and qemu-web GitLab repositories. If you need it for any reason (you shouldn't), please ask the owners for the GitLab organization.
If you need to use the key, also please coordinate with qemu.org owners to have a "temporary" private key added to ~qemu-deploy/.ssh/authorized_keys first (note: the .ssh/authorized_keys file is made immutable with chattr +i). Only switch to the existing private key when everything works. This ensures for example that the private key is not leaked into job logs!
Creating a new repository
To setup a mirror from an upstream repository to Gitlab:
- Create the new repository on https://gitlab.com/qemu-project
- Click Settings->Repository
- Expand "Mirroring repositories"
- When creating the Pull mirroring rule, choose "Keep divergent refs"
To mirror the repository to GitHub, you will need admin access on Gitlab and GitHub.
- Create the new repository on https://github.com/qemu
- Do not close GitHub, open the source repo https://gitlab.com/qemu-project/projectname
- Click Setting->Repository
- Expand "Mirroring repositories"
- Set "Git repository URL" to ssh://git@github.com/qemu/projectname.git
- Set "Mirror direction" to Push
- Click "Detect host keys"
- Set "Authentication method" to "SSH public key"
- Click "Mirror repository"
- Click the suitcase icon ("Copy SSH public key")
- Go back to GitHub, do not close Gitlab
- Click Settings (on the top bar with Code, Issues, etc.)
- Click Deploy keys (on the left column)
- Click "Add deploy key"
- Type whatever you want for Title ("gitlab mirroring"), paste into key
- Click "Allow write access"
- Click "Add key"
- On Gitlab click the retry icon
To mirror the GitLab repository from qemu.org, you will need root access on qemu.org:
REPONAME=repo.git cd /srv/git git init --bare $REPONAME mv hooks/post-update.sample hooks/post-update git remote add --mirror=fetch gitlab https://gitlab.com/qemu-project/$REPONAME git config remote.gitlab.mirror true echo $REPONAME >> ~gituser/repos