Deploy Flutter web app with GitHub Actions or GitLab CI/CD on Pages in 5 min

Igor Steblii
3 min readMay 1, 2021


Flutter is growing in its popularity from day to day, and now it is even easier to spin it off with web support. Probably the quickest way to see web in action is to deploy it on GitLab pages or GitHub pages. Lets see how to do this in 5 minutes

Create a Flutter app

First step is to create a Flutter project. Since 2.0 web support is native, so we just need to use latest stable version:

flutter channel stable
flutter upgrade
flutter create flutter_web

Update base URL

Assuming that your future repository name will be flutter_web lets update the base URL for correct routing. Open web/index.html and update:

This steps are common for both GitLab & Github platforms.


Create an empty project on the GitHub.

Please, note that your Repository name should be the same as a base URL we updated above

GitHub — create a new project

GitHub Actions

Now let’s add a GitHub actions script. Create a new file: .github/workflows/build-deploy.yml with a next content:

After merging this to master GitHub automatically recognises a new action and triggers a build

GitHub Action in progress

Wait utill pipeline successfully passes

GitHub Actions pipeline

This action will create a new branch gh-pages where you can check out content of the web build

gh-pages branch with release web build content

GitHub Pages

Last step is to enable GitHub Pages for this repo from the Settings/Pages

GitHub pages

GitHub Preview

Visit your pages URL to see deployed web-app


Create an empty project on the GitLab.

Same as for GitHub, make sure that Project slug is the same as the base URL in web/index.html Flutter project

GitLab — new project creation window

GitLab CI/CD

In the root folder create .gitlab-ci.yml file with the next content:

stage: build
image: cirrusci/flutter:stable
- flutter pub get
- flutter build web
- flutter analyze
- flutter test
- build/web

stage: deploy
- cp -r build/web public
- public
- master

GitLab CI/CD

As soon as you merge your changes to master , GitLab will automatically recognise CI/CD configuration and kick off a build

GitLab CI/CD pipeline

GitLab Pages

After pipeline succeeds visit Settings/Pages to find your project URL

GitLab Pages settings page