Update cicd.yml #19
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" ] | |
env: | |
DEV_API_URL: http://localhost:8080 | |
STAGING_API_URL: https://staging.api.example.com | |
PRODUCTION_API_URL: https://api.example.com | |
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 | |
strategy: | |
matrix: | |
env: [dev, staging, production] | |
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=${{ matrix.env == 'dev' && env.DEV_API_URL || matrix.env == 'staging' && env.STAGING_API_URL || env.PRODUCTION_API_URL }}" > .env | |
- name: Build Web | |
working-directory: ./frontend | |
run: flutter build web --release --dart-define=ENV=${{ matrix.env }} | |
- name: Upload Web Build as Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-web-${{ matrix.env }} | |
path: ./frontend/build/web |