Skip to content

edited staging workflow #6815

edited staging workflow

edited staging workflow #6815

name: mobile-app-code-analysis
on: [push]
jobs:
check:
name: check for changes in the mobile app
outputs:
run_code_anaysis: ${{ steps.check_files.outputs.run_code_anaysis }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: check modified app folder
id: check_files
run: |
echo "=============== list modified files ==============="
git diff --name-only HEAD^ HEAD
echo "========== check paths of modified files =========="
git diff --name-only HEAD^ HEAD > files.txt
echo "run_code_anaysis=false" >>$GITHUB_OUTPUT
while IFS= read -r file
do
echo $file
if [[ $file == mobile/* ]]; then
echo "run_code_anaysis=true" >>$GITHUB_OUTPUT
fi
done < files.txt
metrics:
name: App code metrics
needs: [check]
if: needs.check.outputs.run_code_anaysis == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Dart Code Metrics Action
uses: dart-code-checker/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
relative_path: mobile/
pull_request_comment: true
check_unused_files: true
fatal_performance: true
fatal_style: true
fatal_warnings: true
analysis:
name: App code analysis
needs: [check]
if: needs.check.outputs.run_code_anaysis == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: mobile
steps:
- name: Checkout
uses: actions/[email protected]
- name: Authenticate to Google Cloud
uses: google-github-actions/[email protected]
with:
credentials_json: ${{ secrets.GCP_SA_CREDENTIALS }}
- name: Set up gcloud Cloud SDK environment
uses: google-github-actions/[email protected]
- name: Add .env files
run: |
gcloud secrets versions access latest --secret="prod-env-mobile-app" > .env.prod
gcloud secrets versions access latest --secret="prod-env-mobile-app" > .env.dev
- name: Add firebase options files
run: |
cd lib/
gcloud secrets versions access latest --secret="sta-key-mobile-firebase-options-dev" > firebase_options_dev.dart
gcloud secrets versions access latest --secret="sta-key-mobile-firebase_options" > firebase_options.dart
- name: Install Flutter
uses: subosito/[email protected]
with:
channel: 'stable'
- name: Install dependencies
run: flutter pub get
- name: Run code analysis
run: flutter analyze