Job to periodically fetch missing bookmark screenshot cover photos. This Github Action uses Playwright to periodically fetch missing screenshots of saved Bookmarks.
See also:
To run this yourself, you'll need a Github account and a few environment variables. These include a DATABASE_URL
to your Briefkasten database. As well as the connection details to your image hosting service, in this case ImageKit.
- Clone the repository
$ git clone ssh://github.com/ndom91/briefkasten-scrape
$ cd briefkasten-scrape
- Install dependencies
$ npm install
- Build Docker container
$ docker build . -t briefkasten-scrape:latest
- Copy
.env.example
to.env
and edit the file.env
accordingly
$ cp .env.example .env
$ vim .env
DATABASE_URL=postgres://bkAdmin:briefkasten@postgres:5432/briefkasten?sslmode=disable
SUPABASE_KEY=
SUPABASE_URL=
SUPABASE_BUCKET_ID=
BOOKMARKS_CHUNK=5
- Run container
$ docker run \
--rm \
--name briefkasten-scrape \
--network briefkasten_default \
--env-file .env
briefkasten-scrape:latest
This will execute and fetch the first 5 Bookmarks with missing cover images and attempt to capture them with Playwright. They will be uploaded to your image store of choice and then displayed for the user the next time they open their Briefkasten.
- Install your favourite
cron
distribution
$ sudo apt install cronie
- Enable and start the service
$ sudo systemctl enable cronie
$ sudo systemctl start cronie
- Edit your crontab
$ crontab -e
You can configure it to run each 20 minutes; for this, add the following line, and save the file:
*/20 * * * * docker run --rm --name briefkasten-scrape --network briefkasten_default --env-file /PATH/TO/YOUR/.ENV_FILE briefkasten-scrape:latest
--network
is the network the briefkasten
docker compose is using. Probably no need to change.
You need to edit /PATH/TO/YOUR/ENVFILE
above pointing to your ENVFILE
If you want to run your cronjob on another period, you can check the respective codes in https://crontab.guru
Open to all contributions, please stick to formatting settings in your PR though!
MIT