refactor: use REPO_NAMES in preflight.sh

- Replace REPO_1/2/3_NAME in required vars with REPO_NAMES
- Update GitHub repos existence check to iterate REPO_NAMES
- Update runner repos validation to check against REPO_NAMES words

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
S
2026-03-01 10:06:24 -05:00
parent a4e20ab4f1
commit 93aff03b19

View File

@@ -171,14 +171,15 @@ check_runners_ini_format() {
errors=$((errors + 1)) errors=$((errors + 1))
fi fi
# repos: must be "all" or a known REPO_*_NAME # repos: must be "all" or a name from REPO_NAMES
if [[ "$repos" != "all" ]] && [[ -n "$repos" ]]; then if [[ "$repos" != "all" ]] && [[ -n "$repos" ]]; then
local repos_valid=false local repos_valid=false
for var in REPO_1_NAME REPO_2_NAME REPO_3_NAME; do local _rn
if [[ "$repos" == "${!var:-}" ]]; then repos_valid=true; break; fi for _rn in ${REPO_NAMES:-}; do
if [[ "$repos" == "$_rn" ]]; then repos_valid=true; break; fi
done done
if ! $repos_valid; then if ! $repos_valid; then
log_error " → [$section] repos='$repos' (must be 'all' or a known repo name)" log_error " → [$section] repos='$repos' (must be 'all' or a name from REPO_NAMES)"
errors=$((errors + 1)) errors=$((errors + 1))
fi fi
fi fi
@@ -244,7 +245,7 @@ REQUIRED_VARS=(
GITEA_DOMAIN GITEA_INTERNAL_URL GITEA_DOMAIN GITEA_INTERNAL_URL
GITEA_BACKUP_INTERNAL_URL BACKUP_STORAGE_PATH GITEA_BACKUP_INTERNAL_URL BACKUP_STORAGE_PATH
GITHUB_USERNAME GITHUB_TOKEN GITHUB_USERNAME GITHUB_TOKEN
REPO_1_NAME REPO_2_NAME REPO_3_NAME REPO_NAMES
RUNNER_DEFAULT_IMAGE RUNNER_DEFAULT_DATA_PATH LOCAL_RUNNER_DATA_PATH RUNNER_DEFAULT_IMAGE RUNNER_DEFAULT_DATA_PATH LOCAL_RUNNER_DATA_PATH
NGINX_CONTAINER_NAME NGINX_CONF_PATH SSL_MODE NGINX_CONTAINER_NAME NGINX_CONF_PATH SSL_MODE
) )
@@ -496,13 +497,8 @@ check_github_repos() {
return 1 return 1
fi fi
for var in REPO_1_NAME REPO_2_NAME REPO_3_NAME; do local repo
local repo="${!var:-}" for repo in ${REPO_NAMES:-}; do
if [[ -z "$repo" ]]; then
log_error "${var} is empty"
all_ok=1
continue
fi
if ! curl -sf -H "Authorization: token ${GITHUB_TOKEN:-}" "https://api.github.com/repos/${GITHUB_USERNAME}/${repo}" -o /dev/null 2>/dev/null; then if ! curl -sf -H "Authorization: token ${GITHUB_TOKEN:-}" "https://api.github.com/repos/${GITHUB_USERNAME}/${repo}" -o /dev/null 2>/dev/null; then
log_error " → GitHub repo ${repo} not found under ${GITHUB_USERNAME}" log_error " → GitHub repo ${repo} not found under ${GITHUB_USERNAME}"
all_ok=1 all_ok=1