gitea2github/README.md

70 lines
2.1 KiB
Markdown
Raw Permalink Normal View History

2022-02-14 12:52:52 +01:00
# g2g
2022-02-14 13:05:00 +01:00
Simple Gitea hook / service who mirroring all your Gitea repo to Github (with git push --mirror). <br>
2022-02-14 13:05:33 +01:00
*Tested only on Alpine-Linux with Gitea server.* <br>
2022-02-14 13:05:00 +01:00
*The script requires bash, jq, curl, grep and git.*
2022-02-14 12:52:52 +01:00
2022-02-14 13:05:33 +01:00
<br>
2022-02-14 13:01:33 +01:00
2022-02-14 12:52:52 +01:00
This should be easily adapted to other distributions without too many modifications, it should certainly be necessary to modify the location where the cronjob is installed (/etc/periodic/15min) for Debian/Arch/... based system.
2022-02-14 13:05:00 +01:00
<br>
2022-02-14 13:01:33 +01:00
2022-02-14 13:05:00 +01:00
**BE VERY CAREFUL !! : <br>
2022-02-14 12:59:21 +01:00
If a Github repo already exists with the same name as a Gitea repo but with different content, the whole Github repository will be overwritten !**
2022-02-14 12:52:52 +01:00
2022-02-14 13:03:38 +01:00
<br>
2022-02-14 13:01:33 +01:00
2022-02-14 12:59:21 +01:00
### How the hook is triggered :
2022-02-14 12:52:52 +01:00
2022-02-14 12:59:21 +01:00
- Every 15min, a cronjob install the hook in the repos of the configured .
- Every 15min, a cronjob launches the synchronization of the whole repo (git push --mirror).
- When a Gitea depo receives a push, the hook (.hooks/post-receive.d/github_mirror) is triggered and start the synchronization on Github.
2022-02-14 12:52:52 +01:00
2022-02-14 12:59:21 +01:00
### What does the script do :
2022-02-14 12:52:52 +01:00
2022-02-14 12:59:21 +01:00
- Clone your Gitea repositories on Github.
- Automatically create a new repository on Github if it does not exist.
- Synchronize the description.
- Synchronize the stat (private/public) of the repository.
2022-02-14 12:52:52 +01:00
2022-02-14 12:59:21 +01:00
### What the script doesn't do :
2022-02-14 12:52:52 +01:00
2022-02-14 12:59:21 +01:00
- Does not manage several different accounts.
- Do not delete any Github repo (if you delete a Gitea repo, you will have to do it manually on Github).
- Does not synchronize anything from Github to Gitea.
2022-02-14 12:52:52 +01:00
2022-02-14 12:59:21 +01:00
*(The creation of Github repositories and the retrieval of information from Gitea repositories is done through the official API with curl).*
2022-02-14 12:52:52 +01:00
2022-02-14 13:03:38 +01:00
<br>
2022-02-14 13:01:33 +01:00
2022-02-14 12:52:52 +01:00
#### Install
2022-02-14 13:03:38 +01:00
```shell
2022-02-14 12:52:52 +01:00
apk add bash jq curl grep
2023-01-20 13:58:29 +01:00
git config --system --add safe.directory '*'
2022-02-14 13:01:33 +01:00
wget "https://git.rokin.in/Rokin/gitea2github/raw/branch/master/g2g.sh"
2022-02-14 13:42:30 +01:00
# * edit the file with your infos *
2022-02-14 12:59:21 +01:00
cp -f g2g.sh /usr/bin/g2g
2022-02-14 12:52:52 +01:00
chown root:root /usr/bin/g2g
chmod 755 /usr/bin/g2g
g2g service install
```
#### Uninstall
2022-02-14 13:03:38 +01:00
```shell
2022-02-14 12:52:52 +01:00
g2g hook uninstall
g2g service uninstall
rm -f /usr/bin/g2g
```
#### Usage
2022-02-14 13:03:38 +01:00
```shell
#Manual push (single repo):
2022-02-14 12:52:52 +01:00
g2g mirror <repo_name>
2022-02-14 13:03:38 +01:00
#Manual push (all repo):
2022-02-14 12:52:52 +01:00
/etc/periodic/15min/github_mirror_sync
```