Skip to content

Instantly share code, notes, and snippets.

@yungwarlock
Created October 15, 2023 16:54
Show Gist options
  • Save yungwarlock/a18413a1374d7e4733eaef3e9ae1d6a1 to your computer and use it in GitHub Desktop.
Save yungwarlock/a18413a1374d7e4733eaef3e9ae1d6a1 to your computer and use it in GitHub Desktop.
Simple Github action to build flutter project
name: Mobile
on:
workflow_dispatch:
push:
branches: [master]
permissions:
contents: read
pull-requests: read
jobs:
android_build:
name: Android Mobile Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Java
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "12.x"
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.0"
channel: "stable"
- name: Install Dependencies
run: flutter pub get
- name: Build Android app
run: flutter build apk
- name: "Tar files"
run: tar -cvf artifacts.tar build/app/outputs/flutter-apk/*.apk
- name: Upload Android apk
uses: actions/upload-artifact@v3
with:
name: artifacts
retention-days: 1
path: artifacts.tar
android_staging_deploy:
name: Android Mobile Deploy
needs: android_build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: artifacts
- name: Untar Artifacts
run: tar -xvf artifacts.tar
- id: auth
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.FIREBASE_SA }}"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v1"
- id: message
name: Get commit message
run: echo message=$(git tag -l --format='%(contents)'${REF}) >> "$GITHUB_OUTPUT"
env:
REF: ${{ github.event.push.after }}
- name: Install firebase
run: npm install -g firebase-tools
# Deploy to only staging users
- name: Deploy Android app to Firebase app distribution
env:
message: ${{ steps.message.outputs.message }}
run: |
firebase appdistribution:distribute build/app/outputs/flutter-apk/app-release.apk \
--project=<example> \
--app hello \
--release-notes "$message" \
--groups "staging, admin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment