Skip to content

Commit

Permalink
fix: mastodonbot (#187)
Browse files Browse the repository at this point in the history
attempt to fix the mastodon publisher:

- that the bot does not post on merged pull request, but only on
releases (it used to publish the merge and the release)
- that the script is found (./post_to_mastodon.sh does not seem to work,
perhaps $(pwd)/post_to_mastodon.sh will?)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Chores**
	- Updated GitHub Actions workflow for Mastodon posting.
- Modified workflow trigger to run on push to the main branch after a
pull request merge.
- Changed environment variable to use release tag name instead of pull
request title.
	- Added a step to check out the repository.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
cmeesters authored Jan 17, 2025
1 parent ae72d2b commit 9c2fd03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/post_to_mastodon.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Extract version from PR title passed as environment variable
version="${PR_TITLE##* }"
# Extract version from PR tag passed as environment variable
version="${PR_TITLE#v}"

# Validate version format
if ! [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/post_to_mastodon.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Post to Mastodon on PR Merge

on:
pull_request:
push:
branches:
- main
types:
Expand All @@ -15,13 +15,13 @@ jobs:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Post to Mastodon
uses: nick-fields/retry@v2
with:
timeout_minutes: 2
max_attempts: 3
command: |
git checkout ${{ github.event.pull_request.head.sha }}
export MASTODONBOT="${{ secrets.MASTODONBOT }}"
export PR_TITLE="${{ github.event.pull_request.title }}"
./post_to_mastodon.sh
export PR_TITLE="${{ github.event.release.tag_name }}"
$GITHUB_WORKSPACE/post_to_mastodon.sh

0 comments on commit 9c2fd03

Please sign in to comment.