Skip to content

Daily Post Good First Issues to BlueSky #88

Daily Post Good First Issues to BlueSky

Daily Post Good First Issues to BlueSky #88

name: Daily Post Good First Issues to BlueSky
on:
workflow_dispatch:
schedule:
- cron: "0 12 * * *" # Runs daily at 12:00 PM UTC
jobs:
post_good_first_issue:
runs-on: ubuntu-latest
steps:
- name: Install jq
run: sudo apt-get install -y jq
- name: Fetch Good First Issues
id: fetch_issues
run: |
# Uncomment the following line for production:
response=$(curl -s https://ost.ecosyste.ms/api/v1/issues?recent=true)
# For testing purposes, create a sample response as a single-line JSON
# response='[{"project":{"name":"Project A","language":"Python"},"title":"Issue 1","html_url":"www.github.com/issue1","labels":["good first issue"]},{"project":{"name":"Project B","language":"JavaScript"},"title":"Issue 2","html_url":"www.github.com/issue2","labels":["good first issue"]},{"project":{"name":"Project C","language":"Ruby"},"title":"Issue 3","html_url":"www.github.com/issue3","labels":["bug"]}]'
echo "$response" > issues.json
- name: Check if there are issues
run: |
if [[ ! -s issues.json ]] || [[ "$(jq length issues.json)" -eq 0 ]]; then
echo "No issues found. Exiting."
exit 0
fi
echo "Issues found. Proceeding."
- name: Prepare Posts
id: prepare_posts
env:
default_hashtags: " #climate #sustainability #opensource #opensustain #goodfirstissue #goodfirstissues"
run: |
jq -c --arg hashtags "$default_hashtags" '[.[] | select(.labels[] == "good first issue") | {
message: (.title + " (" + .project.language + ") - " + .project.name + " " + .html_url + $hashtags)
}]' issues.json > posts.json
echo "Prepared posts:"
cat posts.json
- name: Send posts to Bluesky
env:
BLUESKY_IDENTIFIER: ${{ secrets.BLUESKY_IDENTIFIER }}
BLUESKY_PASSWORD: ${{ secrets.BLUESKY_PASSWORD }}
run: |
echo "Authenticating with Bluesky..."
auth_response=$(curl -s -X POST "https://bsky.social/xrpc/com.atproto.server.createSession" \
-H "Content-Type: application/json" \
-d '{
"identifier": "'"$BLUESKY_IDENTIFIER"'",
"password": "'"$BLUESKY_PASSWORD"'"
}')
ACCESS_JWT=$(echo "$auth_response" | jq -r '.accessJwt')
DID=$(echo "$auth_response" | jq -r '.did')
if [[ -z "$ACCESS_JWT" || "$ACCESS_JWT" == "null" ]]; then
echo "❌ Failed to authenticate with Bluesky. Exiting."
exit 1
fi
echo "✅ Authenticated as $DID"
while IFS= read -r post; do
post_message=$(echo "$post" | jq -r '.message')
created_at=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
post_payload=$(jq -n \
--arg repo "$DID" \
--arg text "$post_message" \
--arg createdAt "$created_at" \
'{
repo: $repo,
collection: "app.bsky.feed.post",
record: {
"$type": "app.bsky.feed.post",
text: $text,
createdAt: $createdAt
}
}')
echo "Posting to Bluesky: $post_message"
curl -s -X POST "https://bsky.social/xrpc/com.atproto.repo.createRecord" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_JWT" \
-d "$post_payload"
echo "Waiting 5 seconds before the next post..."
sleep 5
done < <(jq -c '.[]' posts.json)
echo "✅ All posts sent to Bluesky."