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. We have specified that this process shuld work on ubuntu by below line : 

runs-on: ubuntu-latest

we have specified actions which need to perform when our actual work starts. you can see  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.