Merge pull request 'fix: fix: setup_ops_repo should create ops repo under disinto-admin, not the authenticated bot (#240)' (#247) from fix/issue-240 into main
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
This commit is contained in:
commit
4a94370215
2 changed files with 10 additions and 6 deletions
14
bin/disinto
14
bin/disinto
|
|
@ -1007,13 +1007,15 @@ setup_ops_repo() {
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"${forge_url}/api/v1/orgs/${org_name}/repos" \
|
"${forge_url}/api/v1/orgs/${org_name}/repos" \
|
||||||
-d "{\"name\":\"${ops_name}\",\"auto_init\":true,\"default_branch\":\"${primary_branch}\",\"description\":\"Operational data for ${org_name}/${ops_name%-ops}\"}" >/dev/null 2>&1; then
|
-d "{\"name\":\"${ops_name}\",\"auto_init\":true,\"default_branch\":\"${primary_branch}\",\"description\":\"Operational data for ${org_name}/${ops_name%-ops}\"}" >/dev/null 2>&1; then
|
||||||
# Fallback: create under the repo owner namespace (FORGE_REPO owner)
|
# Fallback: use admin API to create repo under the target namespace.
|
||||||
local repo_owner="${FORGE_REPO%%/*}"
|
# POST /api/v1/users/{username}/repos creates under the authenticated user,
|
||||||
|
# not under {username}. The admin API POST /api/v1/admin/users/{username}/repos
|
||||||
|
# explicitly creates in the target user's namespace regardless of who is authed.
|
||||||
curl -sf -X POST \
|
curl -sf -X POST \
|
||||||
-H "Authorization: token ${admin_token:-${FORGE_TOKEN}}" \
|
-H "Authorization: token ${admin_token:-${FORGE_TOKEN}}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"${forge_url}/api/v1/users/${repo_owner}/repos" \
|
"${forge_url}/api/v1/admin/users/${org_name}/repos" \
|
||||||
-d "{\"name\":\"${ops_name}\",\"auto_init\":true,\"default_branch\":\"${primary_branch}\",\"description\":\"Operational data\"}" >/dev/null 2>&1 || true
|
-d "{\"name\":\"${ops_name}\",\"auto_init\":true,\"default_branch\":\"${primary_branch}\",\"description\":\"Operational data for ${org_name}/${ops_name%-ops}\"}" >/dev/null 2>&1 || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add all bot users as collaborators with appropriate permissions
|
# Add all bot users as collaborators with appropriate permissions
|
||||||
|
|
@ -1980,7 +1982,9 @@ p.write_text(text)
|
||||||
echo "Branch: ${branch}"
|
echo "Branch: ${branch}"
|
||||||
|
|
||||||
# Set up {project}-ops repo (#757)
|
# Set up {project}-ops repo (#757)
|
||||||
local ops_slug="${forge_repo}-ops"
|
# Always use disinto-admin as the ops repo owner — forge_repo owner may be
|
||||||
|
# the calling user (e.g. johba) but the ops repo belongs to disinto-admin.
|
||||||
|
local ops_slug="disinto-admin/${project_name}-ops"
|
||||||
local ops_root="/home/${USER}/${project_name}-ops"
|
local ops_root="/home/${USER}/${project_name}-ops"
|
||||||
setup_ops_repo "$forge_url" "$ops_slug" "$ops_root" "$branch"
|
setup_ops_repo "$forge_url" "$ops_slug" "$ops_root" "$branch"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
name = "disinto"
|
name = "disinto"
|
||||||
repo = "johba/disinto"
|
repo = "johba/disinto"
|
||||||
ops_repo = "johba/disinto-ops"
|
ops_repo = "disinto-admin/disinto-ops"
|
||||||
forge_url = "http://localhost:3000"
|
forge_url = "http://localhost:3000"
|
||||||
repo_root = "/home/YOU/dark-factory"
|
repo_root = "/home/YOU/dark-factory"
|
||||||
ops_repo_root = "/home/YOU/disinto-ops"
|
ops_repo_root = "/home/YOU/disinto-ops"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue