rsokl / Learning_Python

Source material for Python Like You Mean it
https://www.pythonlikeyoumeanit.com/
Other
163 stars 54 forks source link

Proposition: automate build and deploy with GitHub actions #151

Open alexander-ding opened 4 years ago

alexander-ding commented 4 years ago

I've been experimenting with GitHub actions to setup workflows that trigger when you, say, push to the master branch. Specifically, we can setup an action to

  1. Build the HTML from source every time new material is pushed
  2. Backup the current HTML as an Artifact (available for download), which would allow us to get rid of docs_backup

Another potential change an automated action can open us up to is the separation of source and generated code. Since you don't have to manually deploy both rounds of code, storing them on separate branches becomes very feasible. Personally, I think having the HTML available on the default branch clutters the commit history and distracts the developers. Since GitHub's hosting service only allows you to deploy from the master branch, you can deploy your source code to a different branch (say, source) and make it the repository's default branch, while hosting from the master branch. This is the setup I've been using for my personal website, and it works like a charm. In order to make a change, all I need to do is to push the update of my source code to the source branch, and the website will update automatically.

Obviously, this would be a significant restructure of the repository, so I'm just pitching the idea here. I think it'd be very worthwhile.

rsokl commented 4 years ago

I really like this idea and agree that it would be worthwhile. I would like to add some CI, like a link-checker (#67), that would gate PRs as well.

I think that my only hang-ups are:

Any thoughts on this?

alexander-ding commented 4 years ago

I would not be able to view the HTML that actually got built before it goes live. That is, there could be a discrepancy between the environment I am using to build the site vs environment used by GitHub actions

I don't think there would be too much real difference between the HTML you build locally (using conda) and the HTML GitHub builds if you setup the GitHub action to create a similar environment to your local machine (Windows 10 image, Conda, create-env from the .yaml file in the repo). I did some research, and there are already actions on the GitHub market that supports this sort of setup (see setup-conda). Even if you absolutely need to verify the build, there are tools (see act) that allow you to run the actions locally.

There is that and the potential overhead of wanting to upgrade the tech stack for the website, but having do surgery on the actions instead of simply experimenting with my own local environment. Perhaps it is simple enough to finalize whatever tweaks I am doing and simply revise the environment for the actions.

In my experience it's not much work to revise the environment once you've got the setup figured out locally.