Skip to content

Create post_to_mastodon.yml #1

Create post_to_mastodon.yml

Create post_to_mastodon.yml #1

name: Post to Mastodon on PR Merge
on:
pull_request:
types: [closed]
jobs:
post_to_mastodon:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Post to Mastodon
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_BODY: ${{ github.event.pull_request.body }}
PR_USER: ${{ github.event.pull_request.user.login }}
MASTODON_INSTANCE_URL: 'https://fosstodon.org'
run: |
PR_COMMENT=$(echo "$PR_BODY" | head -c 100) # Truncating to 100 characters, adjust as needed
STATUS="Pull request #$PR_NUMBER by @$PR_USER merged: $PR_TITLE - $PR_COMMENT"
curl -X POST -H "Authorization: Bearer ${{ secrets.MASTODON_ACCESS_TOKEN }}" \
-F "status=$STATUS" \
$MASTODON_INSTANCE_URL/api/v1/statuses