CI For Your Flutter App With GitHub Actions For Beginners

Sandra Thon
2 min readNov 3, 2022

--

Whether you are a solo developer or in a small or big team, CI jobs make us feel safe to publish high-quality code formatted code without test regressions

In this post, we are gonna look at how to use GitHub Actions to implement the perfect job for our Flutter application.

  1. Go on Actions

2. Go on New workflow

3. Click on set up a workflow yourself

4. Give the file any name with the extension .yml

I like to call it flutter-ci.yml

and copy-paste this file:

name: Flutter CIon:
pull_request:
branches:
- main

# on: push # Default will running for every branch.

jobs:
build:
# This job will run on ubuntu virtual machine
runs-on: ubuntu-latest
steps:

# Setup Java environment in order to build the Android app.
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '12.x'

# Setup the flutter environment.
- uses: subosito/flutter-action@v1
with:
channel: 'beta' # 'dev', 'alpha', default to: 'stable'
# flutter-version: '1.12.x' # you can also specify exact version of flutter

# Get flutter dependencies.
- run: flutter pub get

# Check for any formatting issues in the code.
- run: flutter format --set-exit-if-changed .
# Statically analyze the Dart code for any errors.
- run: flutter analyze .

# Run widget tests for our flutter project.
- run: flutter test

# Build apk.
- run: flutter build apk

# Upload generated apk to the artifacts.
- uses: actions/upload-artifact@v1
with:
name: release-apk
path: build/app/outputs/apk/release/app-release.apk

This will work for every pull request created in GitHub, if you would like to run it just when you push something into master/main, change pull_request to push .

5. Start commit

And that’s all!

If you liked this post do not forget to follow me here on Medium or on Twitter!

--

--