-
Notifications
You must be signed in to change notification settings - Fork 4
Add enhanced Bluesky posting workflow with contextual messaging and robust error handling #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@gvegayon 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: gvegayon <893619+gvegayon@users.noreply.github.com>
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install requests python-dateutil | ||
|
|
||
| - name: Post to Bluesky | ||
| env: | ||
| BLUESKY_USERNAME: ${{ secrets.BLUESKY_USERNAME }} | ||
| BLUESKY_PASSWORD: ${{ secrets.BLUESKY_PASSWORD }} | ||
| GOOGLE_CALENDAR_API_KEY: ${{ secrets.GOOGLE_CALENDAR_API_KEY }} | ||
| run: | | ||
| python .github/scripts/post_to_bluesky.py | ||
| continue-on-error: true # Don't fail the workflow if Bluesky credentials aren't set up yet No newline at end of file |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the problem, explicitly set the minimal necessary permissions for the GITHUB_TOKEN used in this workflow to avoid using the potentially broader repository or organization-wide defaults. This is achieved by adding a permissions: block in the workflow yaml. Place the permissions: block at the root-level of the YAML file to apply to all jobs within the workflow, unless some jobs individually require more/other permissions, which is not the case here. The most restrictive reasonable value for workflows that only read repository contents is permissions: contents: read. This should be added after the name: and before the on: (trigger) block, typically at the top of the file.
-
Copy modified lines R2-R3
| @@ -1,4 +1,6 @@ | ||
| name: Post to Bluesky | ||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| schedule: |
Co-authored-by: gvegayon <893619+gvegayon@users.noreply.github.com>
gvegayon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, I need the CI to also run on demand (if I wanted to update something on the fly). In addition, I need the workflow to run in PRs and commits as well, but in dry-mode, meaning that it will only generate the message and print it on the screen, so the user can inspect the message when they look at the CI logs.
Co-authored-by: gvegayon <893619+gvegayon@users.noreply.github.com>
I've implemented both requested features:
The workflow now:
Changes in commit 6f7388e. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
gvegayon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, address the issues
|
|
||
| message_parts.append("\n\n#DataScience #Utah #AI #MachineLearning") | ||
|
|
||
| return "".join(message_parts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some important notes about the message. It should include:
- The date/day, e.g., "Join us Wednesday, Sep 3" if it is the Monday message, or "Join us today" if it is the Wednesday message.
- The speaker.
- The title of the talk.
- The #datascience and #ai tags.
- Link to the datascience seminar website. For this, you should use Bluesky's richtext facets. The text in the message should be something like "more details here", with the word "here" linking to https://datascience.utah.edu/seminar
If it happens that the message is too long (check the Bluesky limits), then truncate the title only, using ellipses. Bluesky's API does not provide support for emojis and automatic links to topics via tag attributes "#", you need to use the documentation I provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've implemented all the requested message format improvements:
- ✅ Date/day context: "Join us Wednesday, Sep 3" for Monday messages, "Join us today" for Wednesday messages
- ✅ Speaker extraction from event descriptions using regex patterns
- ✅ Title inclusion in the formatted message
- ✅ Updated hashtags to use #datascience and #ai specifically
- ✅ Implemented Bluesky richtext facets for proper linking - "More details here" with "here" linking to https://datascience.utah.edu/seminar
The message now includes proper contextual timing and rich text linking as requested. Commit: 8401a3f
.github/scripts/post_to_bluesky.py
Outdated
| def format_event_message(event): | ||
| """Format the event data into a Bluesky post message""" | ||
| if not event: | ||
| return "Join us for our next Utah Data Science Center event! Check our website for details: https://datascience.utah.edu/seminar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's no event, then return an empty string. Then, no posting should be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! The format_event_message function now returns an empty string when no event is found, and the main function checks for this and skips posting entirely.
if not message:
logger.info("No upcoming events found. Skipping post.")
returnThis ensures no posting occurs when there are no events to announce. Commit: 8401a3f
Co-authored-by: gvegayon <893619+gvegayon@users.noreply.github.com>
I've addressed all the issues:
The workflow now handles network restrictions gracefully and provides improved message formatting. Commit: 8401a3f Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This PR implements an automated workflow that posts Utah Data Science Center events to Bluesky with enhanced message formatting and robust error handling.
Key Features
Smart Contextual Messaging
Automated Posting Schedule
Dry-Run Mode for Development
Robust Error Handling
Message Format Example
The "here" text links directly to https://datascience.utah.edu/seminar using Bluesky's rich text facets.
Setup
To enable posting, add these GitHub repository secrets:
BLUESKY_USERNAME: Your Bluesky handle (e.g.,username.bsky.social)BLUESKY_PASSWORD: Bluesky app password (create in Settings → App Passwords)The workflow runs safely without errors even before credentials are added.
Fixes #44.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.