CodeBlanks Logo Icon CodeBlanks

GitHub Actions

Set up a Flutter CI flow with GitHub Actions.

What is GitHub Actions?

GitHub Actions is a system that runs automated jobs (CI) on code pushed to a GitHub repository. You define a workflow by placing a YAML file in the .github/workflows/ folder. A typical Flutter pipeline includes flutter test and flutter build steps.

name: CI
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: subosito/flutter-action@v2
      - run: flutter test

CI steps

A typical Flutter CI pipeline: check out code (actions/checkout), install the Flutter SDK (subosito/flutter-action), fetch dependencies (flutter pub get), run tests (flutter test), and build (flutter build apk). Each run: line is a shell command.

Practice CI steps list

In main, define a list of String CI steps in order: 'checkout', 'flutter pub get', 'flutter test', 'flutter build apk'. Print the 3rd element (index 2) with print.

Starter code

main.dart
void main() {
  // CI adımları listesi tanımla: checkout, flutter pub get, flutter test, flutter build apk
  // listenin 3. elemanini (index 2) yazdir
}

Sample solution

main.dart
void main() {
  final steps = <String>[
    'checkout',
    'flutter pub get',
    'flutter test',
    'flutter build apk',
  ];
  print(steps[2]);
}

Expected output

flutter test

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 In which folder is a GitHub Actions workflow file placed?

  • bin/
  • lib/
  • .github/workflows/ Correct answer
  • test/

Explanation: Workflow YAML files go in the .github/workflows/ folder; GitHub scans it to start CI jobs.

2 Workflow trigger

Question
on: [____, pull_request]
Answer
on: [push, pull_request]

Explanation: A GitHub Actions workflow is triggered via the on: key; push and pull_request are the most common triggers, while merge and commit are not direct triggers.

3 GitHub Actions matches

Term Meaning
GitHub Actions CI system
workflow Automated workflow
.github/workflows Workflow folder
run Shell command

All lessons in Advanced