Add Forgejo Actions workflow templates and repo promotion helper
Canonical ci-smoke, container-build-push, and multirepo build templates for railiance01 runners. Documents adoption path for tier 1-3 repos.
This commit is contained in:
parent
58c3c48d00
commit
dc760eb58e
6 changed files with 284 additions and 0 deletions
51
tools/promote-repo-to-forgejo.sh
Executable file
51
tools/promote-repo-to-forgejo.sh
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env bash
|
||||
# Promote a coulomb repo to Forgejo (tier 2.5): mirror, flip remotes, add ci-smoke.
|
||||
set -euo pipefail
|
||||
|
||||
REPO="${1:?usage: promote-repo-to-forgejo.sh <repo-name> [repo-path]}"
|
||||
REPO_PATH="${2:-$HOME/${REPO}}"
|
||||
ORG=coulomb
|
||||
FORGEJO_API="${FORGEJO_API:-https://forgejo.coulomb.social/api/v1}"
|
||||
TOKEN_FILE="${FORGEJO_TOKEN_FILE:-/tmp/forgejo-tegwick-api-token}"
|
||||
TEMPLATE="${PROMOTE_CI_TEMPLATE:-$HOME/railiance-enablement/workflows/ci-smoke.yaml}"
|
||||
|
||||
if [[ ! -f "${TOKEN_FILE}" ]]; then
|
||||
echo "Missing API token at ${TOKEN_FILE}" >&2
|
||||
exit 1
|
||||
fi
|
||||
TOKEN=$(cat "${TOKEN_FILE}")
|
||||
AUTH=(-H "Authorization: token ${TOKEN}")
|
||||
|
||||
code=$(curl -sS -o /dev/null -w '%{http_code}' "${AUTH[@]}" "${FORGEJO_API}/repos/${ORG}/${REPO}")
|
||||
if [[ "${code}" == "404" ]]; then
|
||||
echo "==> Creating ${ORG}/${REPO} on Forgejo"
|
||||
curl -fsS -X POST "${FORGEJO_API}/orgs/${ORG}/repos" "${AUTH[@]}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"name\":\"${REPO}\",\"private\":false,\"auto_init\":false}" >/dev/null
|
||||
elif [[ "${code}" == "200" ]]; then
|
||||
echo "==> ${ORG}/${REPO} already exists on Forgejo"
|
||||
else
|
||||
echo "Unexpected API status ${code} for ${ORG}/${REPO}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "${REPO_PATH}"
|
||||
|
||||
mkdir -p .forgejo/workflows
|
||||
if [[ ! -f .forgejo/workflows/ci-smoke.yaml ]]; then
|
||||
cp "${TEMPLATE}" .forgejo/workflows/ci-smoke.yaml
|
||||
git add .forgejo/workflows/ci-smoke.yaml
|
||||
git commit -m "Add Forgejo CI smoke workflow (enablement template)"
|
||||
fi
|
||||
|
||||
if git remote get-url origin 2>/dev/null | grep -q forgejo-remote; then
|
||||
echo "==> Remotes already on Forgejo"
|
||||
else
|
||||
git remote rename origin gitea
|
||||
git remote add origin "forgejo-remote:${ORG}/${REPO}.git"
|
||||
echo "==> Remotes: origin=forgejo-remote, gitea=legacy"
|
||||
fi
|
||||
|
||||
echo "==> Pushing ${REPO_PATH} to Forgejo"
|
||||
git push -u origin main
|
||||
echo "==> Promoted ${REPO}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue