cbrgm / mastodon-github-action

Use this Action to send a toot (message) from a GitHub actions workflow to Mastodon.
Apache License 2.0
31 stars 1 forks source link
action github mastodon toot workflow

Mastodon Send GitHub Action

<img src="https://upload.wikimedia.org/wikipedia/commons/4/48/Mastodon_Logotype_%28Simple%29.svg" width="120px" align="right" />

Use this action to send a toot (message) from a GitHub actions workflow to Mastodon.

GitHub release Go Report Card go-lint-test go-binaries container

Inputs

Outputs

Container Usage

This action can be executed independently from workflows within a container. To do so, use the following command:

podman run --rm -it ghcr.io/cbrgm/mastodon-github-action:v2 --help

Workflow Usage

First, open /settings/applications/new of your instance on your browser and create new application. Once the application is created set the following repository secrets

Use the following step in your GitHub Actions Workflow:


- name: Send toot to Mastodon
  id: mastodon
  uses: cbrgm/mastodon-github-action@v2
  with:
    access-token: ${{ secrets.MASTODON_ACCESS_TOKEN }} # access token
    url: ${{ secrets.MASTODON_URL }} # https://example.social
    message: "Hello from GitHub Actions!"

Advanced usage:

- name: Send toot to Mastodon with additional options
  id: mastodon_toot
  uses: cbrgm/mastodon-github-action@v2
  with:
    access-token: ${{ secrets.MASTODON_ACCESS_TOKEN }} # Mastodon access token for authentication.
    url: ${{ secrets.MASTODON_URL }} # Mastodon instance URL, e.g., https://example.social.
    message: "Hello from GitHub Actions! Check out our latest update." # The content of the toot.
    visibility: "unlisted" # Make the toot unlisted to avoid spamming public timelines.
    sensitive: "true" # Mark the toot as sensitive.
    spoiler-text: "Latest Update" # Provide a content warning for the actual message.
    language: "en" # ISO 639 language code for the toot.
    scheduled-at: "2024-01-01T00:00:00Z" # Schedule the toot for a future date/time.

# Example on how to use outputs from the Mastodon action step.
- name: Get toot information
  run: |
    echo "Toot ID: ${{ steps.mastodon_toot.outputs.id }}"
    echo "Toot URL: ${{ steps.mastodon_toot.outputs.url }}"
    echo "Scheduled at: ${{ steps.mastodon_toot.outputs.scheduled_at }}"

You can find more usage examples in the ./example-workflows subfolder.

About message visibility types

Contributing & License