From 8446ca72bf12d05e05b5ef720ce1aa9ff6a90c9b Mon Sep 17 00:00:00 2001 From: Erick Date: Sun, 31 Oct 2021 14:44:36 -0300 Subject: [PATCH] docs: some steps to use gh pages (#1059) * docs: some steps to use gh pages * Update doc/platforms.md * Apply suggestions from code review Co-authored-by: Lukas Klingsbo Co-authored-by: Lukas Klingsbo --- doc/platforms.md | 50 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/doc/platforms.md b/doc/platforms.md index 197fd2091..1454a7979 100644 --- a/doc/platforms.md +++ b/doc/platforms.md @@ -14,7 +14,7 @@ don't support them. This means that issues happening outside the stable channel To use Flame on web you need to make sure your game is using the CanvasKit/[Skia](https://skia.org/) renderer. This will increase performance on the web, as it will use the `canvas` element instead of -separate DOM elements. +separate DOM elements. To run your game using skia, use the following command: ```console @@ -26,6 +26,54 @@ To build the game for production, using skia, use the following: $ flutter build web --release --web-renderer canvaskit ``` +## Deploy your game to GitHub Pages + +One easy way to deploy your game online, is to use [GitHub Pages](https://pages.github.com/). +It is a cool feature from GitHub, by which you can easily host web content from your repository. + +Here we will explain the easiest way to get your game hosted using GitHub pages. + +First thing, lets create the branch where your deployed files will live: + +```bash +git checkout -b gh-pages +``` + +This branch can be created from `main` or any other place, it doesn't matter much. After you push that +branch go back to your `main` branch. + +Now you should add the [flutter-gh-pages](https://github.com/bluefireteam/flutter-gh-pages) +action to your repository, you can do that by creating a file `gh-pages.yaml` under the folder +`.github/workflows`. + +```yaml +name: Gh-Pages + +on: + push: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: subosito/flutter-action@v1 + - uses: bluefireteam/flutter-gh-pages@v7 + with: + baseHref: /NAME_OF_YOUR_REPOSITORY/ + webRenderer: canvaskit +``` + +Be sure to change `NAME_OF_YOUR_REPOSITORY` to the name of your GitHub repository. + +Now, whenever you push something to the `main` branch, the action will run and update your +deployed game. + +The game should be available at an URL like this: +`https://YOUR_GITHUB_USERNAME.github.io/YOUR_REPO_NAME/` + ### Web support When using Flame on the web some methods may not work. For example `Flame.device.setOrientation` and