This is a playground for automating bluesky accounts via merged GitHub pull requests.
Currently, scripts for the actions are under ./actions
folder. Records of requested and performed actions are under ./records
.
- .github/ # Contains workflows alive
- actions/ # scripts for the actions
- lib/
- test/
- integration.js # This can be run locally to test process.js on a test account
- process.js # a script that takes a path/to/new/name.json to perform actions
- login-and-validate.js # part of process.js, can be run alone to validate a JSON
- records/
- new/ # Where requests can be added in the form of JSON via pull requests.
# It contains some existing examples with the name xxx.json.example
- processed/ # Requests in the new folder will be moved here with information
# about the performed actions added. The file will be renamed
# to YYYY-MM-DD-ID.json, where ID is incremental index for files
# processed on that date.
-
Set up repository secrets for accounts.
- For each account that the automation controls, give it a name (this will be used as part of the environment variables, so ideally it should just be a capitalized word), for example
PIXEL
. - Go to https://bsky.app/settings/app-passwords and create an app password for that account
- Set up a repository secret
BLUESKY_APP_PASSWORD_$ACCOUNT
(e.g.BLUESKY_APP_PASSWORD_PIXEL
) to be that app password.
- For each account that the automation controls, give it a name (this will be used as part of the environment variables, so ideally it should just be a capitalized word), for example
-
Make sure that in the GitHub workflows where
BLUESKY_APP_PASSWORD_
andBLUESKY_APP_PASSWORD_
environment variables are used to run scripts under theactions/
folder, the account handle and the account app password are added in there. For example:env: BLUESKY_IDENTIFIER_PIXEL: pixel-voyager.bsky.social BLUESKY_APP_PASSWORD_PIXEL: ${{ secrets.BLUESKY_APP_PASSWORD_PIXEL }}
There can be multiple accounts configured in the environment variables. The GitHub actions will process JSON files with an "account" field specifying which account they want to use to perform the action.
- Open a pull request targeting the
main
branch to add a JSON file or multiple JSON files torecords/new/
.- The file name can be anything, as long as it ends with
.json
, though its better to give it a descriptive name likerepost.json
. The file will be renamed and moved torecords/processed
later so it doesn't matter how it is named during the draft phase. - For example, see #8
- The file name can be anything, as long as it ends with
- The JSON files must contain:
"action"
: currently"post"
,"repost"
,"quote-post"
and"reply"
are supported"account"
: it should be one of the account set up in the previous section, for example"PIXEL"
if the corresponding secret isBLUESKY_APP_PASSWORD_PIXEL
.- For other fields see the examples under
records/new
.
- When the PR is opened, the validate-json workflow will run to make sure the JSON files are correctly filled. It will verify the URLs filled in the JSON files are valid.
- When the PR is merged, the process-json workflow will run to perform the requested actions, and when it's done, it will move the processed JSON files to
./records/processed
and renamed the file toYYYY-MM-DD-ID.json
where ID is an incremental ID based on the number of files already processed on that date. It will also add in additional details of the performed actions (e.g. CID and URI of the posted post).
$ nvs add 22 # Or use nvm if you prefer
$ nvs use 22
$ corepack enable
$ cd actions
$ yarn install
There aren't a lot of tests right now. Though to run the test locally to perform a series actions on a live test account, you could do:
cd ./actions
node --env-file=./.env.bluesky test/integration.js
All files starting with .env are ignored in this repository, you could save the credentials there, like in the .env.bluesky
used above, if the account is named PIXEL
, it should have:
BLUESKY_IDENTIFIER_PIXEL=... # The Bluesky handle
BLUESKY_APP_PASSWORD_PIXEL=... # The app password