feat(landing): Move landing into separate repository
This commit is contained in:
118
pipeline.sh
118
pipeline.sh
@@ -6,7 +6,6 @@ RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
MAGENTA='\033[0;35m'
|
||||
NC='\033[0m'
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
@@ -14,7 +13,6 @@ TEMP_DIR=$(mktemp -d)
|
||||
DEPLOY_FLAG=false
|
||||
RUN_FRONTEND=true
|
||||
RUN_BACKEND=true
|
||||
RUN_LANDING=true
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$TEMP_DIR"
|
||||
@@ -49,16 +47,14 @@ show_help() {
|
||||
cat << EOF
|
||||
Usage: $(basename "$0") [OPTIONS]
|
||||
|
||||
CI/CD Pipeline Script - Runs frontend, backend, and landing builds in parallel with optional deployment
|
||||
CI/CD Pipeline Script - Runs frontend and backend builds in parallel with optional deployment
|
||||
|
||||
OPTIONS:
|
||||
--deploy Deploy to server after successful build
|
||||
--frontend-only Run only the frontend job
|
||||
--backend-only Run only the backend job
|
||||
--landing-only Run only the landing page job
|
||||
--no-frontend Skip the frontend job
|
||||
--no-backend Skip the backend job
|
||||
--no-landing Skip the landing page job
|
||||
--help Show this help message
|
||||
|
||||
EXAMPLES:
|
||||
@@ -66,8 +62,6 @@ EXAMPLES:
|
||||
$(basename "$0") --deploy # Run all jobs and deploy
|
||||
$(basename "$0") --frontend-only # Run only frontend job
|
||||
$(basename "$0") --backend-only # Run only backend job
|
||||
$(basename "$0") --landing-only # Run only landing page job
|
||||
$(basename "$0") --no-landing # Run frontend and backend only
|
||||
$(basename "$0") --frontend-only --deploy # Run frontend and deploy
|
||||
|
||||
ENVIRONMENT:
|
||||
@@ -244,73 +238,10 @@ backend_job() {
|
||||
return ${PIPESTATUS[0]}
|
||||
}
|
||||
|
||||
landing_job() {
|
||||
local log_file="$TEMP_DIR/landing.log"
|
||||
local use_prefix=$1
|
||||
|
||||
(
|
||||
set +e
|
||||
|
||||
echo "==================== LANDING JOB ===================="
|
||||
log_info "Starting landing page build..."
|
||||
|
||||
cd "$SCRIPT_DIR/landing" || exit 1
|
||||
|
||||
log_info "Installing dependencies..."
|
||||
pnpm install --frozen-lockfile
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "Dependencies installation failed"
|
||||
exit 1
|
||||
fi
|
||||
log_success "Dependencies installed"
|
||||
|
||||
log_info "Running linting..."
|
||||
pnpm lint
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "Linting failed"
|
||||
exit 1
|
||||
fi
|
||||
log_success "Linting passed"
|
||||
|
||||
log_info "Running type checking..."
|
||||
pnpm type-check
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "Type checking failed"
|
||||
exit 1
|
||||
fi
|
||||
log_success "Type checking passed"
|
||||
|
||||
log_info "Building Docker image..."
|
||||
mkdir -p "$SCRIPT_DIR/.buildx-cache/landing"
|
||||
docker buildx build \
|
||||
--platform linux/amd64 \
|
||||
--tag "gitea.lugnas.de/denis/legalconsenthub-landing:latest" \
|
||||
--tag "gitea.lugnas.de/denis/legalconsenthub-landing:$GIT_SHA" \
|
||||
--file ./Dockerfile \
|
||||
--cache-from type=local,src="$SCRIPT_DIR/.buildx-cache/landing" \
|
||||
--cache-to type=local,dest="$SCRIPT_DIR/.buildx-cache/landing",mode=max \
|
||||
--push \
|
||||
..
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "Docker build failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_success "Docker image built and pushed successfully"
|
||||
log_info "Image: gitea.lugnas.de/denis/legalconsenthub-landing:latest"
|
||||
log_info "Image: gitea.lugnas.de/denis/legalconsenthub-landing:$GIT_SHA"
|
||||
|
||||
exit 0
|
||||
) 2>&1 | if [ "$use_prefix" = true ]; then prefix_output "LANDING" "$MAGENTA"; else cat; fi | tee "$log_file"
|
||||
|
||||
return ${PIPESTATUS[0]}
|
||||
}
|
||||
|
||||
run_jobs() {
|
||||
local job_count=0
|
||||
[ "$RUN_FRONTEND" = true ] && ((job_count++))
|
||||
[ "$RUN_BACKEND" = true ] && ((job_count++))
|
||||
[ "$RUN_LANDING" = true ] && ((job_count++))
|
||||
|
||||
local run_parallel=false
|
||||
if [ "$job_count" -gt 1 ]; then
|
||||
@@ -323,12 +254,10 @@ run_jobs() {
|
||||
|
||||
local frontend_exit=0
|
||||
local backend_exit=0
|
||||
local landing_exit=0
|
||||
|
||||
if [ "$run_parallel" = true ]; then
|
||||
local frontend_pid=""
|
||||
local backend_pid=""
|
||||
local landing_pid=""
|
||||
|
||||
if [ "$RUN_FRONTEND" = true ]; then
|
||||
frontend_job true &
|
||||
@@ -342,12 +271,6 @@ run_jobs() {
|
||||
log_info "Backend PID: $backend_pid"
|
||||
fi
|
||||
|
||||
if [ "$RUN_LANDING" = true ]; then
|
||||
landing_job true &
|
||||
landing_pid=$!
|
||||
log_info "Landing PID: $landing_pid"
|
||||
fi
|
||||
|
||||
log_info "Waiting for jobs to complete..."
|
||||
echo ""
|
||||
|
||||
@@ -360,10 +283,6 @@ run_jobs() {
|
||||
wait $backend_pid
|
||||
backend_exit=$?
|
||||
fi
|
||||
if [ -n "$landing_pid" ]; then
|
||||
wait $landing_pid
|
||||
landing_exit=$?
|
||||
fi
|
||||
set -e
|
||||
else
|
||||
if [ "$RUN_FRONTEND" = true ]; then
|
||||
@@ -379,13 +298,6 @@ run_jobs() {
|
||||
backend_exit=$?
|
||||
set -e
|
||||
fi
|
||||
|
||||
if [ "$RUN_LANDING" = true ]; then
|
||||
set +e
|
||||
landing_job false
|
||||
landing_exit=$?
|
||||
set -e
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
@@ -411,15 +323,6 @@ run_jobs() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$RUN_LANDING" = true ]; then
|
||||
if [ "$landing_exit" -eq 0 ]; then
|
||||
log_success "Landing job completed successfully"
|
||||
else
|
||||
log_error "Landing job failed with exit code $landing_exit"
|
||||
has_failure=true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$has_failure" = true ]; then
|
||||
log_error "One or more jobs failed. Aborting pipeline."
|
||||
exit 1
|
||||
@@ -486,7 +389,6 @@ main() {
|
||||
only_flag_used=true
|
||||
RUN_FRONTEND=true
|
||||
RUN_BACKEND=false
|
||||
RUN_LANDING=false
|
||||
shift
|
||||
;;
|
||||
--backend-only)
|
||||
@@ -497,18 +399,6 @@ main() {
|
||||
only_flag_used=true
|
||||
RUN_FRONTEND=false
|
||||
RUN_BACKEND=true
|
||||
RUN_LANDING=false
|
||||
shift
|
||||
;;
|
||||
--landing-only)
|
||||
if [ "$only_flag_used" = true ]; then
|
||||
log_error "Cannot combine multiple --*-only flags"
|
||||
exit 1
|
||||
fi
|
||||
only_flag_used=true
|
||||
RUN_FRONTEND=false
|
||||
RUN_BACKEND=false
|
||||
RUN_LANDING=true
|
||||
shift
|
||||
;;
|
||||
--no-frontend)
|
||||
@@ -519,10 +409,6 @@ main() {
|
||||
RUN_BACKEND=false
|
||||
shift
|
||||
;;
|
||||
--no-landing)
|
||||
RUN_LANDING=false
|
||||
shift
|
||||
;;
|
||||
--help)
|
||||
show_help
|
||||
;;
|
||||
@@ -533,7 +419,7 @@ main() {
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$RUN_FRONTEND" = false ] && [ "$RUN_BACKEND" = false ] && [ "$RUN_LANDING" = false ]; then
|
||||
if [ "$RUN_FRONTEND" = false ] && [ "$RUN_BACKEND" = false ]; then
|
||||
log_error "No jobs to run. At least one job must be enabled."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user