TheJadav

How to implement GitHub Actions for Flutter Application

Implement GitHub actions for Flutter application. Automation in flutter app.

Automation is necessary now a days, here I am talking about project development. Every time we add new feature, we run our test case and build application. We can automate this process with help of GitHub Actions for Flutter. Here I am sharing yml file details for one of application. This will process every commit and check test and buildable app after that commit.

# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the "master" branch
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v1
        with:
          java-version: '12.x'
          
      - uses: subosito/flutter-action@v2
        with:
          flutter-version: '3.0.5'
          channel: 'stable'
          
      - run: flutter pub get
      - run: flutter test
      - run: flutter build apk
      - run: flutter build appbundle

Let me explain what it will do.

 

name: CI

This will define name for workflow.

on:

This specifies what operation we need to do. We have specified Push and pullRequest operation on master branch(please check in code).

jobs:

This defines what to do when particular action happens. This line will run our action on ubuntu :

runs-on: ubuntu-latest

Actions which need to perform when our actual work starts is defined by below lines : 

uses: actions/checkout@v3

uses: actions/setup-java@v1

We can also specify particular version also, like we have specified for java and flutter. 

Once all setup done. We are able to run commands, which we run in our terminal to update pub or get pub. You can see in ending section.

Note : This file will be created withing .github/workflows directory with .yml file extension. This file is formatted in intended format, so be careful when editing this file.

 

Thank you for reading this post, please share your experience also. 

Share this content:

Share:

More Posts

Introduction to Kotlin: A Versatile and Modern Programming Language

Kotlin, a versatile and modern programming language, offers developers a concise, safe, and interoperable coding experience. With features like null safety, extension functions, and coroutines, Kotlin enhances productivity and readability, making it an attractive choice for Android development and beyond. Whether you’re new to programming or an experienced developer, exploring Kotlin opens up a world of possibilities for building robust and expressive applications.

Mastering the Android Activity Lifecycle: A Comprehensive Guide

The Android Activity Lifecycle is a fundamental concept for Android developers. It defines how an Activity behaves during its lifecycle, from creation to destruction. Understanding the Activity Lifecycle is crucial for managing resources efficiently and delivering a smooth user experience. In this blog post, we’ll briefly introduce the different states an Activity can be in and the main callback methods associated with each state. Let’s dive in and explore this important aspect of Android app development!

Table of Contents

Send Us A Message