Update build.gradle #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SafeZones CI/CD | |
on: | |
push: | |
branches: [ "develop" ] | |
pull_request: | |
branches: [ "develop" ] | |
jobs: | |
backend: | |
name: Build & Test Backend (Maven) | |
runs-on: macos-latest | |
env: | |
SPRING_PROFILES_ACTIVE: dev | |
DATABASE_URL: jdbc:mysql://localhost:3306/dev_db | |
DATABASE_USER: root | |
DATABASE_PASSWORD: root | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Cache Maven Dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2 | |
key: maven-${{ runner.os }}-${{ hashFiles('**/pom.xml') }} | |
restore-keys: maven-${{ runner.os }}- | |
- name: Build Spring Boot App | |
working-directory: ./backend | |
run: mvn clean package -DskipTests | |
- name: Run Tests | |
working-directory: ./backend | |
run: mvn test | |
frontend: | |
name: Build & Test Flutter App | |
runs-on: macos-latest | |
env: | |
API_URL: http://localhost:8080 | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: 3.x | |
cache: true | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Install Dependencies | |
working-directory: ./frontend | |
run: flutter pub get | |
- name: Generate Environment File | |
working-directory: ./frontend | |
run: | | |
echo "API_URL=$API_URL" > .env | |
- name: Build APK | |
working-directory: ./frontend | |
run: flutter build apk --release | |
- name: Upload APK as Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-apk | |
path: ./frontend/build/app/outputs/flutter-apk/app-release.apk |