I wrote a while ago about an approach to automatically publish Web apps to GitHub Pages using GitHub Workflows, looking specifically at approaches for Flutter and for Godot Engine. I have used that approach a few times since blogging about it, and the one step I really never liked was that necessity to push something to gh-pages
before
it would work. I could never remember the command-line syntax either, so I kept having to look up
my own blog posts to make it work.
This morning, in preparation for the start of classes and recording a video tutorial, I came across the recently-released manual event triggering with workflow_dispatch
. It turns out that by
adding one line to my existing workflow specification, I can make it so that the workflow can be
started from GitHub's site.
Let's cut to the chase. Here's what I consider the simpler approach:
-
Include
workflow_dispatch:
in youron:
triggers in the workflow specification (see below for an example). -
After your initial push, go to your Actions tab on GitHub, and you should see your workflow listed there
with a button to manually start it. Go ahead and do that.
- At the time of this writing, I noticed that the UI did not automatically update to show that the workflow was running, so try reloading the page after starting the action.
-
Once the action is done, go to the project Settings, and you should now be able to select
the
gh-pages
branch that was created by your workflow as the source of your GitHub Pages site.
That's it. Save the option, give it a moment to publish, and you should be able to see your site hosted on GitHub pages. All subsequent pushes will run the workflow automatically as before, without your needing the manual step.
I have updated my public gists of the workflow specifications to include the necessary modification, and I'll link the other two blog posts here for folks who want my latest approach explained. Below is the Godot Engine approach, just to round out this post.
No comments:
Post a Comment