From 22c8092f1c4d36ff92dc8acb79012edc20ecd8a1 Mon Sep 17 00:00:00 2001 From: TPTBusiness Date: Sat, 9 May 2026 17:53:11 +0200 Subject: [PATCH] feat: auto-post releases to Mastodon and X/Twitter via GitHub Actions --- .github/workflows/release-social.yml | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/release-social.yml diff --git a/.github/workflows/release-social.yml b/.github/workflows/release-social.yml new file mode 100644 index 00000000..fe159514 --- /dev/null +++ b/.github/workflows/release-social.yml @@ -0,0 +1,49 @@ +name: Release Social Post + +on: + release: + types: [published] + +jobs: + post-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Extract release info + id: release + run: | + TAG="${{ github.event.release.tag_name }}" + BODY="${{ github.event.release.body }}" + # Truncate body to ~400 chars for social media + SHORT_BODY=$(echo "$BODY" | head -5 | tr '\n' ' ' | cut -c1-400) + echo "tag=$TAG" >> $GITHUB_OUTPUT + echo "body=$SHORT_BODY" >> $GITHUB_OUTPUT + echo "url=${{ github.event.release.html_url }}" >> $GITHUB_OUTPUT + + - name: Post to Mastodon + if: ${{ secrets.MASTODON_ACCESS_TOKEN != '' }} + run: | + STATUS="🚀 NexQuant ${{ steps.release.outputs.tag }} released! + + ${{ steps.release.outputs.body }} + + ${{ steps.release.outputs.url }}" + + curl -s -X POST "${{ secrets.MASTODON_INSTANCE }}/api/v1/statuses" \ + -H "Authorization: Bearer ${{ secrets.MASTODON_ACCESS_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "$(jq -nc --arg status "$STATUS" '{"status": $status}')" + + - name: Post to X (Twitter) + if: ${{ secrets.X_API_KEY != '' }} + uses: nearform-actions/github-action-notify-twitter@v3 + with: + message: | + 🚀 NexQuant ${{ steps.release.outputs.tag }} released! + ${{ steps.release.outputs.url }} + twitter-api-key: ${{ secrets.X_API_KEY }} + twitter-api-secret-key: ${{ secrets.X_API_SECRET_KEY }} + twitter-access-token: ${{ secrets.X_ACCESS_TOKEN }} + twitter-access-token-secret: ${{ secrets.X_ACCESS_TOKEN_SECRET }}