GitHub

Download der „Latest Version“ eines beliebigen Projektes:

  • per Browser: https://github.com/$USERNAME/$PROJECT/releases/latest

  • per curl:

    REPO='linuxfabrik/monitoring-plugins'
    curl --output $(basename ${REPO}) https://codeload.github.com/${REPO}/tar.gz/refs/tags/$(curl --silent https://api.github.com/repos/${REPO}/releases/latest | jq -r '.tag_name')
    

URLs zu den einzelnen RSS-Feeds:

Stargazers over Time

git clone https://github.com/caarlos0/starcharts.git
cd starcharts
go run main.go

Anschliessend mit dem Browser http://127.0.0.1:3000 aufrufen, und Repository-Name eingeben, z.B. linuxfabrik/monitoring-plugins.

Oder einfacher (Direkt-Aufruf, aber rate-limited): https://starchart.cc/Linuxfabrik/monitoring-plugins.svg

GitHub Image Cache leeren

Dieses nette Bash-Skript erledigt den Job:

cd /tmp
curl --location --remote-name https://raw.githubusercontent.com/mpyw/hub-purge/master/hub-purge.sh
chmod +x hub-purge.sh
/tmp/hub-purge.sh linuxfabrik/monitoring-plugins linuxfabrik/lfops ...

Migration von GitLab zu GitHub

Public GitLab-Repos lassen sich über https://github.com/new/import inkl. Commits und Revision History leicht importieren; bei privaten Repos sollte auf dem GitLab-Server 2FA temporär abgeschaltet werden, um Fehlern wie No source repositories were detected at <repo_url>. Please check the URL and try again. vorzubeugen.

Im Gegensatz zum sehr guten GitLab-Importer sind die Möglichkeiten bei GitHub sehr bescheiden - GitLab-Issues lassen sich beispielsweise darüber nicht importieren. Hier hilft das Tool https://github.com/piceaTech/node-gitlab-2-github, welches dafür unter der Haube das GitHub-API nutzt.

Bemerkung

Die Nutzung des GitHub-APIs ist auf 5000 Requests pro Stunde begrenzt (das Login-API dagegen beispielsweise auf 60 Requests/h) . Ein Repo mit ca. 2’500 Issues sollte sich noch problemlos importieren lassen.

Man sollte pro Issue-Migration mit ca. 3 bis 5 Sekunden Dauer rechnen.

node-gitlab-2-github installieren:

git clone https://github.com/piceaTech/node-gitlab-2-github.git
cd node-gitlab-2-github
npm i

Das GitLab-Repo in das GitHub-Repo spiegeln:

GITLAB_REPO=lib.git
GITLAB_REPO_URL=git@git.linuxfabrik.ch:linuxfabrik/$GITLAB_REPO

GITHUB_REPO=lib.git
GITHUB_REPO_URL=git@github.com:username/$GITHUB_REPO

git clone --mirror $GITLAB_REPO_URL
cd $GITLAB_REPO

# Push to GitHub using the ``--mirror`` option.  The ``--no-verify`` option skips any hooks.
git push --no-verify --mirror $GITHUB_REPO_URL

# Set push URL to the mirror location
git remote set-url --push origin $GITHUB_REPO_URL

# To periodically update the repo on GitHub with what you have in GitLab
git fetch --prune origin
git push --no-verify --mirror

In GitLab muss ein Personal Access Token mit „read_api“-Rechten erzeugt werden.

Auf GitHub unter Settings > Developer settings > Personal access tokens ein neues Token mit „repo“-Scope erzeugen.

Anschliessend node-gitlab-2-github konfigurieren:

# TypeScript File:
cp /root/node-gitlab-2-github/sample_settings.ts /root/node-gitlab-2-github/settings.ts
/root/node-gitlab-2-github/sample_settings.ts
// just showing what we changed, differences only
export default {
  gitlab: {
    url: 'https://git.linuxfabrik.ch',
    token: 'my_gitlab_token',
    projectId: 1,   // the ID of the GitLab Project
    sessionCookie: 'my_session_cookie', // get it from your webbrowser, using the developer tools
  },
  github: {
    owner: 'company',
    token: ' my_github_token',
    token_owner: 'username',
    repo: 'lib',
  },
  usermap: {
    'markus.frei': 'username',
    'gitlab.user': 'github.user',
  },
  projectmap: {
    'linuxfabrik/lib': 'username/lib',
    'gitlb/project': 'github-user/github-project',
  },
} as Settings;

Einmalig laufen lassen:

cd /root/node-gitlab-2-github
npm run start

So sieht ein erfolgreicher Run aus:

==================================
Transferring Description
==================================

==================================
Transferring Milestones
==================================

==================================
Transferring Labels
==================================

==================================
Transferring Releases
==================================

==================================
Transferring Issues
==================================

==================================
Transferring Merge Requests
==================================

Transfer complete!

Built on 2024-04-18