Galaxy Social
This repository strives to democratise Galaxy's social media activity. The aim is to encourage collaboration, editing, peer-review of toots and much more. In addition, we might add bots and support to automatise social media activity of awesome community contributions such as PRs, new tools, or events on the Galaxy Hub.
How to tootCreate a Post
tl;dr Create new toot
Create a new *.toot file in this ./toots/ folder. For more details please consult this Readme.
To create a post on Galaxy Social, follow these steps:
-
Create a Branch: Begin by creating a branch in this repository or your forked repository.
-
Add a New File: Within the "posts" folder (or sub-folders), create a new file with the extension ".md" and commit it to your branch.
-
Use the Post Template: Utilize the following template for the post content:
--- media: - bluesky - mastodon - matrix - slack images: - url: https://example.com/a.jpg alt_text: A - url: https://example.org/b.png alt_text: B mentions: bluesky: - a.bsky.social mastodon: - a matrix: - a:matrix.org hashtags: bluesky: - a - b mastodon: - c - d --- Your text content goes here.
Notes on the Template:
-
Everything between the two
---
are metatags and should be in YAML format. -
"media" (Required): Ensure the media name is implemented inside the
plugins.yml
. -
"images" (Optional): Include links to desired images. The alt_text is optional but recommended.
-
"mentions" and "hashtags" (Optional): Follow the specified format as shown in the template.
-
"Your text content goes here." (Required): This is the content that will be posted to social media platforms. When the character limit is reached on a social media, it will be divided into several posts as a thread.
-
Create a Pull Request: Once your post is ready, create a pull request to the main branch from another branch or from your fork
-
Preview and Review: After each pull request, the "Create Preview" GitHub action will run. It will preview the content as a comment to the pull request and highlight any errors that need to be fixed before merging.
-
Publish Your Content: Upon merging the pull request, the "Publish Content" GitHub action will run. The results will be added to
processed_files.json
in the processed_files branch.
By following these steps, you can effectively create and publish posts on Galaxy Social.
Add a New Social Media Platform
Expanding the capabilities of Galaxy Social by adding a new social media platform is a straightforward process. Follow these steps to integrate a new platform:
-
Create a Plugin File: Begin by adding a Python file to the
lib/plugins
folder. This file should contain a class with a function namedcreate_post(content, mentions, hashtags, images, alt_texts)
. This function will handle the process of sending announcements to the desired social media platform. -
Update plugins.yml: Next, update the
plugins.yml
file to include the new social media platform. Follow this template:
- name: name_of_the_media class: file_name.class_name enabled: true config: token: $TOKEN_SAVED_IN_PUBLISH_CONTENT room_id: "room_id"
Ensure to replace name_of_the_media
with the name of the new platform, and file_name.class_name
with the appropriate file and class name for the plugin. The name
is then used in the media
tag in the post file (posts/*.md) to determine the social media.
-
Configuration: In the
config
section, specify any required variables for initializing the plugin class. This may include authentication tokens, room IDs, or other platform-specific parameters. Any configuration that needs to be securely passed with GitHub secrets should be prefixed with$
in order to be easily identifiable within the workflow YAML file. -
GitHub Secrets: Add any tokens or variables required for the plugin to GitHub secrets. This ensures sensitive information is securely stored. Refer to GitHub secrets documentation for guidance on creating secrets.
-
Enable the Plugin: Simply set
enabled: true
to enable the new social media platform. This ensures that it will be implemented when creating posts. -
Update publish_content.yml: Finally, update the
publish_content.yml
file to include an environment variable referencing the token saved in GitHub secrets. Use the following template: (Don't put the prefixed$
in here)
... env: TOKEN_SAVED_IN_PUBLISH_CONTENT: ${{ secrets.TOKEN_SAVED_IN_GITHUB_SECRETS }} ...
Replace TOKEN_SAVED_IN_GITHUB_SECRETS
with the name of the secret containing the token for the new social media platform.
By following these steps, you can seamlessly integrate a new social media platform into Galaxy Social, expanding its reach and functionality.
Duplicate a Social Media Platform with Different Token
If you need to use the same social media platform with different authentication tokens, you can duplicate the entry in the plugins.yml
file. Follow these steps:
-
Duplicate Entry: Copy the entry for the social media platform in the
plugins.yml
file and paste it below the original entry. -
Update Name and Tokens: Change the name of the duplicated entry to reflect the new configuration, and replace the token with the new authentication token.
-
Configuration: Adjust any other configuration parameters as needed for the duplicated entry.
-
Use Name in Post: Remember that the name you specify in the
plugins.yml
file must also be used within themedia
tag when creating a post. Ensure consistency to link the post with the correct social media platform.
By following these steps, you can effectively duplicate a social media platform with a different token for specific use cases or configurations.
Run locally
You can execute this repository on your machine by running lib/galaxy_social.py
with the argument --files Files ...
or --folder FOLDER
to process files, or add --preview
to preview the file as markdown. Also there is --json-out processed_files.json
that could be change where to save the json results output.
Remember to add the env variable that needed for each social media seperatly.
Social media implemented
- Bluesky
- Mastodon
- Matrix: hashtags and alt_text for image are not working!
- Slack: mentions and hashtags are not working!
- Linkedin: not implemented but the first draft of python file is in the plugins.