This commit is contained in:
병준 박 2025-04-26 02:05:38 +00:00
parent 3f2a536903
commit 0aa6626fca

View File

@ -65,11 +65,10 @@ spec:
#!/bin/sh
set -ex
# Git 설치
# 필수 패키지 설치 및 Git 설정
apk add --no-cache git
# Git safe.directory 설정 (모든 경로 허용)
git config --global --add safe.directory '*'
git config --global init.defaultBranch main # master 대신 main 사용
git config --global init.defaultBranch main # 모든 새 저장소 기본 브랜치 설정
TARGETS="$(params.targetProjects)"
SOURCES="$(params.sourceProjects)"
@ -80,32 +79,32 @@ spec:
SOURCES=$(echo "$SOURCES" | cut -s -d' ' -f2-)
TARGET_PATH="/workspace/base/$(params.context)/source/$(params.workspaceName)/${TARGET}"
# 소스 디렉터리 Git 초기화 (main 브랜치)
cd "$SRC"
if [ ! -d .git ]; then
git init -b main
git init -b main # 명시적 main 브랜치 생성
git add .
git commit -m "init"
fi
cd -
# Nx 비대화형 임포트 실행
echo "Importing: $SRC → $TARGET_PATH"
# npx nx import --sourceDirectory="$SRC" --destinationDirectory="$TARGET_PATH" --interactive=false --ref=main
npx nx import "$SRC" "$TARGET_PATH" \
--no-interactive \ # ✅ 올바른 비대화형 플래그
--branch=main \ # 브랜치 명시
--sourceDirectory=. \ # 소스 디렉터리 루트 지정
--destinationDirectory="$TARGET_PATH"
npx nx import "$SRC" "$TARGET" \
--no-interactive \
--branch=main \
--sourceDirectory=.
echo "Updating version to $(params.version)"
# 버전 업데이트
sed -i.bak "s/^version = .*/version = \"$(params.version)\"/" "$TARGET_PATH/Cargo.toml"
rm -f "$TARGET_PATH/Cargo.toml.bak"
# destination(monorepo) 변경사항 커밋 또는 리셋
# 변경사항 커밋 (실패 시 무시)
git add .
git commit -m "auto-commit before nx import" || git reset --hard HEAD
git commit -m "chore: import $TARGET (v$(params.version))" || true
done
- name: git-commit
image: alpine/git:latest
workingDir: /workspace/base/$(params.context)/source