This Action will help you import CSV files to Mastodon, including:
- Follows
- Mutes
- Account blocks
- Lists
- Bookmarks
- Domain blocks
We (me and the script) try our best to auto-detect the import file type so you don't have to specify or care. The import is then performed using the Mastodon API and an Access Token.
Here's how you'd import a singular file if your account is on the dataplatform.social Mastodon instance.
- name: Import CSV to Mastodon
uses: potatoqualitee/influx@v1
with:
server: dataplatform.social
file-path: ./follows.csv
env:
ACCESS_TOKEN: "${{ secrets.ACCESS_TOKEN }}"
If you have a ton of entries to follow/bookmark/ban, note that Mastodon limits API calls to 300 per 5 minutes, which averages 1 second so each call will have a delay of one second. Since GitHub Actions have a 60 minute max, this means that you can only import a max of 3600 items, minus overhead time.
If you're doing a variety of imports (follows, bookmarks, etc), you can dedicate one job per import which can help speed things up if you need.
A Mastodon token is required for this Action to work. Fortuantely, it's very easy to get one.
Go to your Mastodon profile/client/webpage and click Preferences -> Development -> New Application -> Application name: Whatever you like, I named mine Imports -> Limit Permissions (optional) -> Submit
Note
If you limit your permissions too much when you create the app, you may need to recreate it. I was too strict with my permissions and it looked like I could edit them but the edit is like a secondary scope
Click new application link -> Your access token
Once you have your authentication information, you will need to them to your repository secrets.
I named my secret TOKEN
. You can modify the names, though you must ensure that your environmental variables are named appropriately, as seen in the sample code.
Finally, create a workflow .yml
file in your repositories .github/workflows
directory. An example workflow is available below. For more information, reference the GitHub Help Documentation for Creating a workflow file.
server
- Your Mastodon server. If you are [email protected], this would be dataplatform.social.file-path
- The path to the CSV file. Accepts one or many files, directory paths and even web addresses to csv files or zips.type
- The type of file. Not required unless the script can't figure it out.recurse
- When specifying a directory, recurse. Defaults to false.verbose
- Show verbose output. Defaults to true.
None
Use the Exodus
action to find mastodon addresses in your follows and followers, then import them each night at midnight.
Note that if any of your follows or followers have been previously blocked on Mastodon, they will be skipped.
name: Auto-Twitter Import
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
jobs:
export-import:
runs-on: ubuntu-latest
steps:
- name: Check Twitter friends for Maston accounts
uses: potatoqualitee/exodus@v1
id: export
with:
my: follows, followers
env:
BLUEBIRDPS_API_KEY: "${{ secrets.BLUEBIRDPS_API_KEY }}"
BLUEBIRDPS_API_SECRET: "${{ secrets.BLUEBIRDPS_API_SECRET }}"
BLUEBIRDPS_ACCESS_TOKEN: "${{ secrets.BLUEBIRDPS_ACCESS_TOKEN }}"
BLUEBIRDPS_ACCESS_TOKEN_SECRET: "${{ secrets.BLUEBIRDPS_ACCESS_TOKEN_SECRET }}"
- name: Import the results
uses: potatoqualitee/influx@v1
id: import
with:
server: tech.lgbt
file-path: ${{ steps.export.outputs.mastodon-csv-filepath }}
env:
ACCESS_TOKEN: "${{ secrets.ACCESS_TOKEN }}"
You can also use GitHub runtime parameters!
Note that if any of your follows or followers have been previously blocked on Mastodon, they will be skipped.
name: import from web interface
on:
workflow_dispatch:
inputs:
server:
description: 'Your Mastodon server. If you are [email protected], this would be dataplatform.social.'
required: true
file-path:
description: 'The path to the CSV file, using runtime parameters pretty much means you will be specifying a web address.'
required: true
jobs:
import:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Import from CSV or zip
uses: potatoqualitee/influx@v1
with:
server: '${{ github.event.inputs.server }}'
file-path: '${{ github.event.inputs.file-path }}'
env:
ACCESS_TOKEN: "${{ secrets.ACCESS_TOKEN }}"
Then it looks like this, so cool:
I looked at what the web exporter generated and crossed my fingers that it used a standard. Here's how I determine type:
File Type | Location | Looks like |
---|---|---|
Follows | /settings/exports/follows.csv | Columns named "Account address", "Show boosts" and maybe "Notify on new posts" ", "Languages" |
Lists | /settings/exports/lists.csv | No header, two columns formatted like: listname, [email protected] |
Blocked Accounts | /settings/exports/blocks.csv | No heading, only 1 column formatted like: [email protected] |
Mutes | /settings/exports/mutes.csv | Columns named "Account address", "Hide notifications" |
Blocked Domains | /settings/exports/domain_blocks.csv | Just a server name, no http, no second column |
Bookmarks | /settings/exports/bookmarks.csv | Just one column, https and the word statuses |
Here's some extra examples for the inputs.
Input | Example | Another Example | And Another |
---|---|---|---|
server | dataplatform.social | [email protected] | https://dataplatform.social |
file-path | /tmp/follows.csv | follows.csv, blocked.csv | https://funbucket.dev/follows.csv |
Just add your $env:ACCESS_TOKEN
environmental variables to your $profile
and reload, clone the repo, change directories, modify this command and run.
./main.ps1 -Server yourinstance.tld -FilePath C:\temp\csvdir, https://pubs.com/northwind/csvs.zip
Some Mastodon addresses are not resolving properly but that should be fixed soon. It's mostly Mastodon with three-part addresses and unexpected characters in their bio. This impacted 3 accounts of 100 on my own tests.
Also, the following pre-check mostly works and I'll figure that out later. Right now, it just means that there may be additional, unnecessary calls to the server, but it does't impact expected functionality.
Pull requests are welcome!
I think Exodus and Influx could benefit from JavaScript integration to Mastadon, maybe? Making it easy to pick and choose who to import.
- Mastodon Fossilize - This Action will help you backup Mastodon account items to CSV files, including: Follows, Mutes, Account blocks, Lists, Bookmarks, Domain blocks, Followers, and Posts.
- Twitter Exodus - This Action helps Twitter communities find members on Mastodon. Searches lists, hashtags, account followers and more for Mastodon links in their name, bio or pinned tweet. Once found, their info is exported to a CSV file that can be imported into Mastodon.
- Using GitHub Pages to Setup an Alias on Mastodon - This tutorial can help you keep your social media presence without running your own Mastodon server.
You tell me! I'm open to suggestions.
The scripts and documentation in this project are released under the MIT License