update script

This commit is contained in:
Patrick
2025-11-04 19:25:35 +01:00
parent 517f635fbf
commit fef7aaa1be
2 changed files with 11 additions and 72 deletions

View File

@ -135,75 +135,3 @@ jobs:
scp -o StrictHostKeyChecking=no -r frontend/.next root@$SERVER_IP:$WEB_ROOT/
echo "Frontend .next build successfully deployed to $SERVER_IP:$WEB_ROOT/.next"
backend-jobs:
name: Set up Java for Backend Tests and Build
if: ${{ github.ref == 'refs/heads/main' }} # skip
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Java 21 + Maven
run: |
echo "Detecting package manager..."
if command -v apt-get >/dev/null 2>&1; then
PM=apt
elif command -v apk >/dev/null 2>&1; then
PM=apk
elif command -v yum >/dev/null 2>&1; then
PM=yum
else
echo "No known package manager found. Will install JDK manually."
PM=none
fi
echo "Package manager detected: $PM"
if [ "$PM" = "apt" ]; then
apt-get update -y
apt-get install -y openjdk-21-jdk maven wget tar
JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
elif [ "$PM" = "apk" ]; then
apk update
apk add openjdk21 maven wget tar
JAVA_HOME=/usr/lib/jvm/java-21-openjdk
elif [ "$PM" = "yum" ]; then
yum install -y java-21-openjdk-devel maven wget tar
JAVA_HOME=/usr/lib/jvm/java-21-openjdk
else
# Fallback: manual download
JDK_URL="https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz"
mkdir -p /opt/jdk
wget -q -O /tmp/jdk.tar.gz $JDK_URL
tar -xzf /tmp/jdk.tar.gz -C /opt/jdk --strip-components=1
JAVA_HOME=/opt/jdk
fi
# Export JAVA_HOME and update PATH for subsequent steps
echo "JAVA_HOME=$JAVA_HOME" >> $GITEA_ENV
echo "$JAVA_HOME/bin" >> $GITEA_PATH
export JAVA_HOME=$JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH
# Verify Java and Maven installation
java -version
mvn -version
- name: Verify Java setup
run: |
java -version
- name: Verify Java setup
run: |
ls -l $JAVA_HOME/bin/java
file $JAVA_HOME/bin/java || true
java -version
# Run backend tests and build
- name: Test & build backend
working-directory: .
run: |
mvn clean test -Dspring.profiles.active=test
echo "Backend test and build workflow successfully completed."

View File

@ -0,0 +1,11 @@
#! /bin/bash
set -e # Exit immediately if a command exits with a non-zero status
docker compose -f docker-compose-dev.yml down --remove-orphans --volumes
docker system prune -f
docker compose -f docker-compose-dev.yml up -d
echo "Started all containers successfully"