alan-turing-institute / data-safe-haven

https://data-safe-haven.readthedocs.io
BSD 3-Clause "New" or "Revised" License
61 stars 15 forks source link

Automate Gitea mirror creation #1996

Open JimMadge opened 4 months ago

JimMadge commented 4 months ago

Create functions to automate our code ingress process, probably using Gitea API

JimMadge commented 4 months ago

It looks like the API call we want to create a mirror is repoMigrate

JimMadge commented 4 months ago

I made a little script to test this

#!/usr/bin/env sh

http --auth "$1":"$2" localhost:3000/api/v1/repos/migrate clone_addr="$4" repo_name="$3"
```command ❯ ./create_mirror.sh jim password dotfiles https://github.com/JimMadge/dotfiles HTTP/1.1 201 Created Cache-Control: max-age=0, private, must-revalidate, no-transform Content-Type: application/json;charset=utf-8 Date: Tue, 09 Jul 2024 10:40:56 GMT Transfer-Encoding: chunked X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN { "allow_fast_forward_only_merge": true, "allow_merge_commits": true, "allow_rebase": true, "allow_rebase_explicit": true, "allow_rebase_update": true, "allow_squash_merge": true, "archived": false, "archived_at": "1970-01-01T01:00:00+01:00", "avatar_url": "http://localhost:3000/", "clone_url": "http://localhost:3000/jim/dotfiles.git", "created_at": "2024-07-09T11:40:53+01:00", "default_allow_maintainer_edit": false, "default_branch": "main", "default_delete_branch_after_merge": false, "default_merge_style": "merge", "description": "", "empty": false, "fork": false, "forks_count": 0, "full_name": "jim/dotfiles", "has_actions": true, "has_issues": true, "has_packages": true, "has_projects": true, "has_pull_requests": true, "has_releases": true, "has_wiki": true, "html_url": "http://localhost:3000/jim/dotfiles", "id": 2, "ignore_whitespace_conflicts": false, "internal": false, "internal_tracker": { "allow_only_contributors_to_track_time": true, "enable_issue_dependencies": true, "enable_time_tracker": true }, "language": "", "languages_url": "http://localhost:3000/api/v1/repos/jim/dotfiles/languages", "link": "", "mirror": false, "mirror_interval": "", "mirror_updated": "0001-01-01T00:00:00Z", "name": "dotfiles", "object_format_name": "sha1", "open_issues_count": 0, "open_pr_counter": 0, "original_url": "https://github.com/JimMadge/dotfiles", "owner": { "active": false, "avatar_url": "http://localhost:3000/avatars/284f5ca6c261672f413ef3255e5675fd", "created": "2024-07-08T15:11:42+01:00", "description": "", "email": "jim@jmadge.com", "followers_count": 0, "following_count": 0, "full_name": "", "html_url": "http://localhost:3000/jim", "id": 1, "is_admin": false, "language": "", "last_login": "0001-01-01T00:00:00Z", "location": "", "login": "jim", "login_name": "", "prohibit_login": false, "restricted": false, "source_id": 0, "starred_repos_count": 0, "username": "jim", "visibility": "public", "website": "" }, "parent": null, "permissions": { "admin": true, "pull": true, "push": true }, "private": false, "projects_mode": "all", "release_counter": 0, "repo_transfer": null, "size": 22, "ssh_url": "git@localhost:jim/dotfiles.git", "stars_count": 0, "template": false, "updated_at": "2024-07-09T11:40:56+01:00", "url": "http://localhost:3000/api/v1/repos/jim/dotfiles", "watchers_count": 1, "website": "" } ```
Screenshot 2024-07-09 at 11 43 41