Skip to content

Example repository of using GitHub Actions to post to Bluesky from R

Notifications You must be signed in to change notification settings

andrewheiss/bsky-bot-r

Repository files navigation

Build your own Bluesky bot with R!

This is a super barebones skeleton example of how to use GitHub actions to run an R script that posts content to Bluesky.

A few important notes:

  • You need to create a Bluesky app password at https://bsky.app/settings/app-passwords

  • If you’re running this locally, create a file named .Renviron and put this in there:

    BSKY_USER="@your-bluesky-username"
    BSKY_PASS="APP-SPECIFIC-PASSWORD"
  • Add these environment variables to your GitHub repository by going to Settings > Secrets and variables > Actions and creating two new respository secrets with your username and password:

  • Right now, .github/workflows/post-to-bsky.yml is configured to only run manually (it uses on: workflow_dispatch), but you can adjust that to follow a cron schedule or occur after pushing a commit or whatever. See this for all the kinds of events you can use. To trigger the action manually, go to Actions > Name of the workflow > Run workflow…

  • That workflow file uses R’s collection of GitHub Actions to install R, install packages from an {renv} lockfile, and run the code. You can make this as fancy as you want (and you should probably add better reporting, and logging, etc.).

  • Right now, script.R connects to the Bluesky API, generates three random numbers, and posts them to Bluesky. It’s super primitive but it works. In real life, you’d want to:

    1. Maybe make a better wrapper around the API
    2. Do something more exciting than generating random numbers. Parse an RSS feed. Generate random text. Post plots or generative artwork. Whatever you want.

    You can make the repository as complex as you want, too. Not everything has to live in script.R—the workflow file right now is set to run just that, but you can change it to whatever.

About

Example repository of using GitHub Actions to post to Bluesky from R

Topics

Resources

Stars

Watchers

Forks

Languages