Merge pull request #37 from benedettoscala/other/bugfixing #129
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: Flutter CI/CD | |
on: | |
push: | |
branches: | |
- main | |
- development | |
- merge/testing | |
pull_request: | |
branches: | |
- main | |
- development | |
- merge/testing | |
jobs: | |
build: | |
environment: firebase | |
name: Build, Test e Checkstyle | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Java 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' # Puoi scegliere 'zulu' o 'adopt' se preferisci | |
java-version: '17' | |
- name: Set up Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.24' | |
channel: 'stable' | |
- name: Set up Android SDK | |
uses: android-actions/setup-android@v2 | |
with: | |
api-levels: 31 | |
build-tools: 31.0.0 | |
- name: Create private config file | |
run: | | |
mkdir -p ./src/android/app | |
cat <<EOF > ./src/android/app/google-services.json | |
{ | |
"project_info": { | |
"project_number": "${{ secrets.PROJECT_NUMBER }}", | |
"project_id": "civiconnect-13aeb", | |
"storage_bucket": "civiconnect-13aeb.firebasestorage.app" | |
}, | |
"client": [ | |
{ | |
"client_info": { | |
"mobilesdk_app_id": "${{ secrets.MOBILESDK_APP_ID }}", | |
"android_client_info": { | |
"package_name": "it.unisa.civiconnect" | |
} | |
}, | |
"oauth_client": [], | |
"api_key": [ | |
{ | |
"current_key": "${{ secrets.CURRENT_KEY }}" | |
} | |
], | |
"services": { | |
"appinvite_service": { | |
"other_platform_oauth_client": [] | |
} | |
} | |
} | |
], | |
"configuration_version": "1" | |
} | |
EOF | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.x | |
- name: Validate and Fix JSON | |
run: | | |
for file in $(find . -name '*.json'); do | |
echo "Processing $file" | |
python3 -m json.tool "$file" > "${file}_fixed" || exit 1 | |
mv "${file}_fixed" "$file" | |
done | |
- name: Install dependencies | |
working-directory: src # Specifica la cartella src | |
run: flutter pub get | |
- name: Run Checkstyle (Linter) | |
working-directory: src | |
run: flutter analyze | |
- name: Run tests | |
working-directory: src | |
run: flutter test | |
- name: Build APK | |
working-directory: src | |
run: flutter build apk --release | |
env: | |
APIKEY_ANDROID: ${{ secrets.APIKEY_ANDROID }} | |
#APIKEY_IOS: ${{ secrets.APIKEY_IOS }} | |
#APIKEY_MAC: ${{ secrets.APIKEY_MAC }} | |
#APIKEY_WEB: ${{ secrets.APIKEY_WEB }} | |
#APIKEY_WIN: ${{ secrets.APIKEY_WIN }} | |
- name: Clean up | |
run: rm src/android/app/google-services.json |