I just implemented this in WebSerial ESPTool, while adding the auto commit stuff. Basically, the dist folder should be added to .gitignore and some additional options specified in actions (See https://github.com/adafruit/Adafruit_WebSerial_ESPTool/blob/main/.github/workflows/pages.yml#L46-L53).