Source code of one-shot-plantuml. Inspired by real-world-plantuml, the insane developer (it's me) wants to build a tool for PlantUML believers to get PlantUML masterpiece (or shit) newly created on Github.
Thanks to:
- clone the repo
git clone [email protected]:LangInteger/one-shot-plantuml.git
- walk into the directory
cd one-shot-plantuml
- make sure heroku cli is installed and logined
- create your app
heroku create your-app-name
- add buildpacks as infrastructure
- node.js as application entry
heroku buildpacks:set heroku/nodejs
- puppeteer-heroku-buildpack add extra dependencies for puppeteer
heroku buildpacks:add --index 1 https://github.com/jontewks/puppeteer-heroku-buildpack
- node.js as application entry
- deploy to remote
git push heroku main
- add env variables
GITHUB_USERNAME
andGITHUB_PASSWORD
on your application settings dashboard - check application logs
heroku logs --tail
- make some changes and deploy again
git add .
git commit -m "xxx"
git push heroku main
For local test, use heroku local web
.
This project use puppeteer to imitate operations on browsers and thus get puml
files from Github.
The most convinient way to contact with contents on github is using the Github API. But for some reason, there is no open api to get newly created files by their extensions( the usage of /search/code
without specifying a user, an organisation or a repository is impossible).
This reddit post make me think using ghaechive maybe another proper way, but havn't give it a try yet.
Github released the Device Verification feature and enabled it for all accounts that not have two-factor authentication (2FA) enabled. So even with puppeteer to imitate login, we must interact with the verification process.
Many have posted article that suggests Disable / Remove Device Verification, but not got accepted yet and it seems that this feature will continue to work for a thousand years.
Refer to Heroku Doc:
- If an app has a free web dyno, and that dyno receives no web traffic in a 30-minute period, it will sleep
When sleep, the main process and browser process will both be terminated. Since Github relies on cookies to identify devices, it will ask for device verification the next time login recoverd from sleep, which is a disaster.
Luckily there are some ways to stop dynos from hibernate easily, according to this SO thread. This project is using github actions to make regular access to one-shot-plantuml every 20 minutes(but not guaranteed), and thus make the dyno keep active all the time.
Some friends made feedback to me to complain this. With heroku buildpacks set properly, the problem should not happen. So I think it is a heroku bug, and can be resolved by running the buildpacks set process again with following commands:
heroku buildpacks:clear
heroku buildpacks:set heroku/nodejs
heroku buildpacks:add --index 1 https://github.com/jontewks/puppeteer-heroku-buildpack
git commit --allow-empty -m "Adjust buildpacks on Heroku"
git push heroku main
Theses do not have any difference to commands in the Deploy
part, but it just makes the project work.