UPDATE: This post presents what I consider a slightly easier approach.
I spent most of the day trying to find the easiest way for my students to publish Flutter Web apps to GitHub Pages. My quest started at zonble's Medium post, proceeded with my taking a closer look at GitHub's workflow and actions documentation, and finally tripping across the handy GitHub Pages action. After a bunch of testing, I'm feeling confident about my approach, which I will explain below.
The essence of the approach is to use a custom workflow by placing the following file
in your project in the path .github/workflows/workflow.yml
. Then, whenever
you push to master
, the workflow will be triggered and your built application
will be deployed to GitHub Pages.
This approach is susceptible to the known problem with first GitHub Pages deployments using GITHUB_TOKEN. The problem can be entirely
avoided by creating and then specifying a personal access token for the repository.
However, I think a simpler approach—that also requires fewer tokens cluttering up
the configuration—is to do one manual push to gh-pages
, after which
the simpler workflow will work as expected.
My suggestion is, before pushing to the master
branch on GitHub,
push your local copy to the remote gh-pages branch, as shown below.
git push origin master:gh-pages
That's enough for GitHub to recognize that you will be deploying to that branch.
Follow that up with a push to the remote master
branch as usual,
and you should be all set.
No comments:
Post a Comment