Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68f0111c2b | ||
|
|
45087d9de2 | ||
|
|
b622724eb7 | ||
|
|
b5a31b2c6b | ||
|
|
3f11082d3e | ||
|
|
d08d965347 | ||
|
|
83d71ded74 | ||
|
|
dd016182a5 | ||
|
|
9dcb67b262 | ||
|
|
e93a6ec46a | ||
|
|
ba06b02d14 | ||
|
|
4d8da3f145 |
@@ -16,3 +16,11 @@ docker build -t cerc/act-runner:local .
|
||||
1. Bring up the gitea cluster `docker compose up -d`
|
||||
1. Run the script `./initialize-gitea.sh`
|
||||
1. Note the access token printed, it will be needed to publish packages.
|
||||
|
||||
#### Debugging
|
||||
Gitea server logs can be seen via docker logs <container-id>.
|
||||
To enable more verbose log output add an environment variable definition like:
|
||||
```
|
||||
GITEA__log__LEVEL=TRACE
|
||||
```
|
||||
to the `server` definition in `docker-compose.yml` and re-start.
|
||||
|
||||
@@ -42,8 +42,6 @@ cache:
|
||||
port: 0
|
||||
|
||||
container:
|
||||
# Which network to use for the job containers. Could be bridge, host, none, or the name of a custom network.
|
||||
network_mode: bridge
|
||||
# Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker).
|
||||
privileged: true
|
||||
# And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway).
|
||||
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
# Script that calls the Giteap API to delete one repo
|
||||
|
||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
if ! [[ $# -eq 1 ]]; then
|
||||
echo "Illegal number of parameters" >&2
|
||||
exit 1
|
||||
fi
|
||||
repo_to_delete=$1
|
||||
|
||||
if [[ -z "${CERC_GITEA_AUTH_TOKEN}" ]]; then
|
||||
echo "CERC_GITEA_AUTH_TOKEN is not set" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "${CERC_GITEA_API_URL}" ]]; then
|
||||
echo "CERC_GITEA_API_URL is not set" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${CERC_GITEA_MIRROR_REPO}" == "true" ]]; then
|
||||
is_mirror=true
|
||||
else
|
||||
is_mirror=false
|
||||
fi
|
||||
|
||||
gitea_target_org=$(dirname ${repo_to_delete})
|
||||
gitea_target_repo_name=$(basename ${repo_to_delete})
|
||||
# Sanity check the repo name
|
||||
if [[ -z "${gitea_target_org}" ]]; then
|
||||
echo "${repo_to_delete} is not a valid repo name" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "${gitea_target_repo_name}" ]]; then
|
||||
echo "${repo_to_delete} is not a valid repo name" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "****** DELETING repo: ${repo_to_delete}"
|
||||
# Note use: --trace-ascii - \ below to see the raw request
|
||||
delete_response=$( curl -s -X DELETE "${CERC_GITEA_API_URL}/api/v1/repos/${repo_to_delete}" \
|
||||
-H "Authorization: token ${CERC_GITEA_AUTH_TOKEN}" \
|
||||
-H "accept: application/json" \
|
||||
)
|
||||
echo ${delete_response} | jq -r
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
services:
|
||||
server:
|
||||
image: gitea/gitea:1.19.2
|
||||
image: gitea/gitea:1.19.3
|
||||
environment:
|
||||
- USER_UID=1000
|
||||
- USER_GID=1000
|
||||
|
||||
@@ -44,7 +44,7 @@ if [[ ${token_found} != 1 ]] ; then
|
||||
new_gitea_token=$( curl -s -X POST "${GITEA_URL_PREFIX}/api/v1/users/${GITEA_USER}/tokens" \
|
||||
-u ${GITEA_USER}:${GITEA_PASSWORD} \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"'${CERC_GITEA_TOKEN_NAME}'", "scopes": [ "sudo" ] }' \
|
||||
-d '{"name":"'${CERC_GITEA_TOKEN_NAME}'", "scopes": [ "sudo", "package" ] }' \
|
||||
| jq -r .sha1 )
|
||||
echo "This is your gitea access token: ${new_gitea_token}. Keep it safe and secure, it can not be fetched again from gitea."
|
||||
echo "To use with laconic-so set this environment variable: export CERC_NPM_AUTH_TOKEN=${new_gitea_token}"
|
||||
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
|
||||
ORG=$1
|
||||
|
||||
#USERNAME=$1
|
||||
USER_API_URL="https://api.github.com/users/$USERNAME/repos"
|
||||
|
||||
API_URL="https://api.github.com/orgs/$ORG/repos"
|
||||
PAGE=1
|
||||
|
||||
# appears uncoupled from limit of 100 repos
|
||||
PER_PAGE=100
|
||||
|
||||
# Function to retrieve repositories for a given page
|
||||
get_repos() {
|
||||
local page=$1
|
||||
curl -s "$USER_API_URL?page=$page&per_page=$PER_PAGE"
|
||||
}
|
||||
|
||||
# Query GitHub API for the first page of repositories
|
||||
response=$(get_repos $PAGE)
|
||||
|
||||
# Check if organization exists
|
||||
if [[ $response =~ "Not Found" ]]; then
|
||||
echo "Organization not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get total number of repositories
|
||||
total_repos=$(echo "$response" | grep -oE '"full_name": "[^"]+"' | wc -l)
|
||||
|
||||
# Initialize array for repositories
|
||||
repos=()
|
||||
|
||||
# Parse repository names and add to the array
|
||||
repos+=($(echo "$response" | grep -oE '"full_name": "[^"]+"' | awk -F': "' '{print $2}' | tr -d '"'))
|
||||
|
||||
# Calculate number of pages needed
|
||||
num_pages=$((($total_repos + $PER_PAGE - 1) / $PER_PAGE))
|
||||
|
||||
# Loop through the remaining pages and retrieve repositories
|
||||
for ((page=2; page<=num_pages; page++)); do
|
||||
response=$(get_repos $page)
|
||||
repos+=($(echo "$response" | grep -oE '"full_name": "[^"]+"' | awk -F': "' '{print $2}' | tr -d '"'))
|
||||
done
|
||||
|
||||
# Loop through the array and output each repository
|
||||
for repo in "${repos[@]}"; do
|
||||
echo "$repo"
|
||||
bash migrate-repo.sh $repo
|
||||
done
|
||||
|
||||
# Display count of repositories
|
||||
echo "Total Repositories: $total_repos"
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
# Script that calls the Giteap API to migrate one repo from
|
||||
# a source hosting platform into that Gitea instance
|
||||
|
||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
if ! [[ $# -eq 1 ]]; then
|
||||
echo "Illegal number of parameters" >&2
|
||||
exit 1
|
||||
fi
|
||||
repo_to_migrate=$1
|
||||
|
||||
if [[ -z "${CERC_GITEA_AUTH_TOKEN}" ]]; then
|
||||
echo "CERC_GITEA_AUTH_TOKEN is not set" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "${CERC_GITEA_API_URL}" ]]; then
|
||||
echo "CERC_GITEA_API_URL is not set" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${CERC_GITEA_MIRROR_REPO}" == "true" ]]; then
|
||||
is_mirror=true
|
||||
else
|
||||
is_mirror=false
|
||||
fi
|
||||
|
||||
gitea_target_org=$(dirname ${repo_to_migrate})
|
||||
gitea_target_repo_name=$(basename ${repo_to_migrate})
|
||||
# Sanity check the repo name
|
||||
if [[ -z "${gitea_target_org}" ]]; then
|
||||
echo "${repo_to_migrate} is not a valid repo name" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "${gitea_target_repo_name}" ]]; then
|
||||
echo "${repo_to_migrate} is not a valid repo name" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
github_repo_url="https://github.com/${repo_to_migrate}"
|
||||
echo "Migrating repo: ${repo_to_migrate} (mirror:${is_mirror})"
|
||||
# Note use: --trace-ascii - \ below to see the raw request
|
||||
migrate_response=$( curl -s -X POST "${CERC_GITEA_API_URL}/api/v1/repos/migrate" \
|
||||
-H "Authorization: token ${CERC_GITEA_AUTH_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "accept: application/json" \
|
||||
-d @- << EOF
|
||||
{
|
||||
"clone_addr": "${github_repo_url}",
|
||||
"mirror": ${is_mirror},
|
||||
"repo_name": "${gitea_target_repo_name}",
|
||||
"repo_owner": "${gitea_target_org}"
|
||||
}
|
||||
EOF
|
||||
)
|
||||
echo Migrated to: $(echo ${migrate_response} | jq -r .html_url)
|
||||
@@ -16,7 +16,7 @@ http {
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://webservice:8000/;
|
||||
proxy_pass ${LACONIC_ORIGIN_SERVICE_URL};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user