Skip to content

Self-hosted service that helps me share to multiple social media platforms at the same time.

License

Notifications You must be signed in to change notification settings

alexandru/social-publish

Repository files navigation

social-publish

build deploy-latest deploy-release

In implementing POSE (publish on your own site, syndicate elsewhere) I need to publish to multiple social networks. I'm using ifttt.com, but it doesn't do a good job — their LinkedIn integration is most often broken, and Bluesky integration is currently missing.

This project is the start of a simple tool to publish my content to multiple social networks.

  • X (Twitter), Mastodon, and Bluesky support is implemented, LinkedIn is planned (currently supported via an RSS feed meant for ifttt.com)
  • Image upload is supported, with alt-text included 😊
  • Also exports an RSS feed, meant for automation via ifttt.com

Table of Contents

Self-hosting

My docker-compose setup:

version: '3.8'

services:
  # ...
  social-publish:
    container_name: social-publish
    image: ghcr.io/alexandru/social-publish:latest
    restart: always
    healthcheck:
      test: ['CMD-SHELL', 'curl --head http://localhost:3000/ || exit 1']
    ports:
      - '3000:3000'
    env_file:
      - ./envs/social-publish.env
    networks:
      - external_network

Where ./envs/social-publish.env contains:

# Where the server is hosted — needed for correctly generating an RSS feed
BASE_URL="https://your-hostname.com"

# The server's Basic AUTH credentials
SERVER_AUTH_USERNAME="your-username"
SERVER_AUTH_PASSWORD="your-password"

# Bluesky credentials
BSKY_HOST="https://bsky.social"
BSKY_USERNAME="your-username"
BSKY_PASSWORD="your-password"

# Mastodon credentials
MASTODON_HOST="https://mastodon.social"
MASTODON_ACCESS_TOKEN="your-access-token"

# YouTube Oauth1 key and secret (Consumer Keys in the Developer Portal)
TWITTER_OAUTH1_CONSUMER_KEY="Api Key"
TWITTER_OAUTH1_CONSUMER_SECRET="Api Secret Key"

# Used for authentication (https://jwt.io)
JWT_SECRET="random string"

Bluesky credentials

For Bluesky, you'll need an "app password".

Keep it safe, as it grants access to everything.

Mastodon credentials

For Mastodon, you'll need an "access token". Here's how to get one:

  • Go to: https://mastodon.social/settings/applications
  • Create a "New Application"
  • Select write:statuses and write:media for permissions, and unselect everything else
  • Click on the newly created application
  • Copy "your access token"
  • Set the MASTODON_ACCESS_TOKEN environment variable to it

Twitter setup

For Twitter, we're working with Oauth1.

  • Go to: https://developer.twitter.com/en/portal/projects-and-apps
  • Create a project and app
  • In the "Keys and tokens" section of the app, generate "Consumer Keys" and copy the generated "App Key and Secret"
  • In the app's settings, go to "User authentication settings" and add as the "Callback URL": https://<your-domain.com>/api/twitter/callback (replace <your-domain.com> with your domain, obviously)
  • Set the TWITTER_OAUTH1_CONSUMER_KEY and the TWITTER_OAUTH1_CONSUMER_SECRET environment variables
  • Once the server is running, go to https://<your-domain.com>/account and click on "Connect Twitter"

Usage

The available requests for creating a new post are exemplified in test.http.

You can then configure ifttt.com. When adding an "action" to your applet, search for "make a web request".

Or, if you open the webpage in a browser (e.g., http://localhost:3000/), you can use this form:

Screenshot of "Post a New Social Message" form


RSS feed

While this service is able to publish directly to Mastodon and Bluesky, for other social networks you can use the RSS feed, exposed at /rss (e.g., http://localhost:3000/rss) in combination with ifttt.com.

Developing

To start the development server (with incremental compilation, powered by Vite):

npm run dev

You can then navigate to http://localhost:3001 for the frontend, while the backend is available at http://localhost:3000.

To build and test the Docker image locally:

make run-local

See the Makefile for more commands.

License

MIT (see LICENSE.txt)