marianfoo / bluesky-scn-bot

2 stars 0 forks source link

Bluesky SCN Bot

A Node.js script that checks the SAP Community Network (SCN) RSS feeds every 60 minutes and posts new blog entries to your Bluesky account. The bot includes metadata like the blog source (by SAP or by Members), author, and maintains a local list of posted entries to avoid duplicates. It respects Bluesky's rate limits and supports automated deployment via GitHub Actions.

Table of Contents


Features


Prerequisites


Installation

  1. Clone the Repository

    git clone https://github.com/marianfoo/bluesky-rss-bot.git
    cd bluesky-rss-bot
  2. Install Dependencies

    npm install

Configuration

  1. Create a .env File

    In the project root directory, create a file named .env:

    touch .env
  2. Add Your Bluesky Credentials

    Open the .env file and add your Bluesky username and password:

    BLUESKY_USERNAME=your_bluesky_username
    BLUESKY_PASSWORD=your_bluesky_password

    Note: Replace your_bluesky_username and your_bluesky_password with your actual Bluesky credentials.

  3. Secure the .env File

    Ensure the .env file is not tracked by Git by adding it to .gitignore:

    echo '.env' >> .gitignore
  4. Configure GitHub Secrets (For Automated Deployment)

    If using the automated GitHub Actions deployment, set up the following secrets in your GitHub repository settings:

    • SSH_IP: Your server's IP address.
    • SSH_USER: SSH username (e.g., root or another user with deployment permissions).
    • SSH_PRIVATE_KEY: Your SSH private key (ensure it is properly formatted).

Running the Script

Running Locally

  1. Start the Script

    node index.js
  2. Verify Output

    The script should log messages indicating it has logged into Bluesky and is checking the RSS feeds.

Running in Production

For production environments, it's recommended to use a process manager like PM2 to keep the script running continuously.

1. Install PM2 Globally

npm install -g pm2

2. Start the Script with PM2

pm2 start index.js --name bluesky-scn-bot

3. Configure PM2 to Run on Startup

pm2 startup

Follow the instructions output by the command to enable PM2 to run on system startup.

4. Save the PM2 Process List

pm2 save

Automated Deployment

The project includes a GitHub Actions workflow (deploy.yaml) for automated deployment to your server when changes are pushed to the main branch.

Setup

  1. Configure SSH Access

    • Ensure your server accepts SSH connections using a private key.
    • Add your SSH private key to GitHub Secrets as SSH_PRIVATE_KEY.
    • Add your server's IP address and SSH username to GitHub Secrets as SSH_IP and SSH_USER, respectively.
  2. GitHub Actions Workflow

    The deploy.yaml workflow performs the following steps:

    • Checks out the repository.
    • Connects to your server via SSH.
    • Navigates to the bot directory.
    • Pulls the latest changes from the main branch.
    • Installs dependencies.
    • Restarts the bot using PM2.

Usage


Updating the Script in Production

If you prefer to update the script manually, follow these steps:

1. SSH into Your Server

ssh your_username@your_server_ip

2. Navigate to Your Project Directory

cd /path/to/bluesky-scn-bot

3. Stop the Running Script

pm2 stop bluesky-scn-bot

4. Pull the Latest Changes from GitHub

git pull origin main

5. Install Updated Dependencies

If any dependencies have changed, install them:

npm install

6. Restart the Script with PM2

pm2 start index.js --name bluesky-scn-bot

7. Save the PM2 Process List

pm2 save

Logging and Monitoring


License

This project is licensed under the MIT License. See the LICENSE file for details.


Additional Information


Contact


Summary

The Bluesky SCN Bot script automates the process of fetching new blog posts from the SAP Community Network and posting them to your Bluesky account. It handles multiple RSS feeds, includes metadata like the blog source and author, and ensures posts comply with Bluesky's character limit. The script supports automated deployment using GitHub Actions, making it easy to keep your production environment up-to-date.

By following the steps outlined above, you can set up, run, and maintain the bot in both development and production environments.


If you have any questions or need further assistance, feel free to contact the repository maintainer.