First we need to set up a docker python environment:
FROM python:3.7.6-slim
# Set environment varibles
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Set work directory
/// <summary> | |
/// Tests string to see if it is valid IPv4 address | |
/// </summary> | |
/// <param name="ip">String to test</param> | |
/// <returns>True if string is IP address, False otherwise</returns> | |
private bool ValidateIpv4Address(string ip) | |
{ | |
IPAddress address; | |
return ip != null && ip.Count(c => c == '.') == 3 && | |
IPAddress.TryParse(ip, out address); |
In the instance you want to migrate all of your GitHub repositories to gitea, instead of manually importing all repos to github and setting them up to mirror we can import them all at once. When I add a repository to Gitea and specify I want it to be mirrored, Gitea will take charge of periodically querying the source repository and pulling changes in it. I’ve mentioned Gitea previously, and I find it’s improving as it matures. I’ve been doing this with version 1.7.5.
After setting up Gitea and creating a user, I create an API token in Gitea with which I can create repositories programatically. The following program will obtain a list of all Github repositories I have, skip those I’ve forked from elsewhere, and then create the repository in Gitea.
#!/usr/bin/env python -B