This repository hosts an automation workflow that posts upcoming tech events in Thailand to the Thai Tech Calendar Facebook Page.
- At most five times per day, GitHub Actions will run a scheduled job.
- It will find the next event to post. The event:
- Must be in the future.
- Must have not been posted before.
- Must not contain the words
tentative
orTBC
. - Must have not been edited for at least 16 hours.
- It captures the screenshot of the calendar website using Puppeteer, with the event’s info at the top via capture mode.
- It then posts it to Facebook and updates the state file.
Pre-requisites:
- Node.js 18 and pnpm (you can also use our Devbox configuration)
- Docker
Setting up:
-
Run the pptraas server in Docker. This server is used to capture screenshots of the calendar website.
docker compose up -d
-
Install dependencies.
pnpm install
-
Run the script to list the events.
pnpm cli --list-events
This will show you the list of events. It will also select the next event to post. The ID of the next event will be stored in
.data/next.id.txt
. -
Run the script to prepare the post.
pnpm cli --prepare-post
This will prepare the image caption (and other metadata) that will be posted to Facebook. The caption will be printed to the console, while the rest of the metadata will be stored in
.data/post.json
.If you want to tweak how the caption is generated, you can edit
src/preparePost.ts
and run the script again. -
Run the script to generate an image.
pnpm cli --prepare-image
This will generate an image. It looks at
.data/post.json
and reads the URL specified inscreenshotUrl
. Then the script will take a screenshot of that URL, save it to a file, and print the path to that file.If you want to tweak how the image is generated, you can edit
src/prepareImage.ts
and run the script again. Note that the appearance of the image is programmed in techcal.dev website repository; this script only takes a screenshot of the website.