Giter Site home page Giter Site logo

flutter-gh-pages's Introduction

Flutter GH Pages

Automates the build and deployment of your Flutter web app on Github gh pages

Action

To use this action, create an action like the following on your workflows folder

name: Gh-Pages

on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - uses: subosito/flutter-action@v2
      - uses: bluefireteam/flutter-gh-pages@v7

To build a project in a folder other that the root, use the workingDir property

      ...
      - uses: bluefireteam/flutter-gh-pages@v7
        with:
          workingDir: example

By default, the action will use the auto setting for web renderers, to change that you can use the webRenderer property.

More on web renderers here: https://flutter.dev/docs/development/tools/web-renderers

      ...
      - uses: bluefireteam/flutter-gh-pages@v7
        with:
          webRenderer: canvaskit

The possible values for webRenderer are:

  • auto: Use the default Flutter setting, which is based on the device and browser capabilities.
  • canvaskit: Use the CanvasKit renderer, which uses WebGL and WebAssembly to render graphics.
  • html: Use the HTML renderer, which uses DOM elements and CSS to render graphics.
  • both: Use both renderers and generate two versions of the web app, one in the root folder (here would be the CanvasKit version) and one in a subfolder specified by the htmlRoute property.

If you use both as the webRenderer value, you can also specify the name of the subfolder where the HTML version will be placed, using the htmlFolder property. The default value is htmlVersion.

If you've selected the both value for the webRenderer, the HTML variant will be deployed to the htmlRoute directory. By default, this is set to htmlVersion.

      ...
      - uses: bluefireteam/flutter-gh-pages@v7
        with:
          htmlRoute: another-route

By default, the action will send the files to the gh-pages branch, which is the default used by Github Pages. If you need to change that, the targetBranch property can be used

      ...
      - uses: bluefireteam/flutter-gh-pages@v7
        with:
          targetBranch: my-gh-pages-branch

By default, the generated page only works on User or Organization sites ex:user.github.io/. You can change that by specifying the baseHref argument, so the site will work on a Project Site, ex:user.github.io/repoName.

The parameter baseHref must start and end with a forward slash "/". (For projects created on flutter version earlier than 2.5.0, please manually edit the file web/index.html, changing the line <base href="/"> to <base href="$FLUTTER_BASE_HREF">)

      ...
      - uses: bluefireteam/flutter-gh-pages@v7
        with:
          baseHref: /my-repo/

To pass arguments to the builder with --dart-define the customArgs property can be used

      ...
      - uses: bluefireteam/flutter-gh-pages@v7
        with:
          customArgs: --dart-define="simple=example"

And consumed in the code via (const is mandatory!):

void main() async {
  String arg = const String.fromEnvironment('simple'); // arg = "example"
  ...
}

To use github pages with a custom domain, add a file named CNAME to the <project>/web folder whose contents is your domain, like:

subdomain.domain.com

flutter-gh-pages's People

Contributors

erickzanardo avatar noga-dev avatar anleac avatar paulopereira98 avatar spydon avatar abdulsalamabdulrahman avatar brylie avatar keyskull avatar merrit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.