Repository navigation
Refactor fetch-x-feed workflow for better error handling - #74
Merged
Merged
Conversation
Signed-off-by: パン君 <yamazakimotionpg@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
The workflow no longer pushes committed updates back to the repository (so runs can succeed without updating the feed).
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Refactors the Fetch X media feed GitHub Actions workflow to make the X API fetch + JSON generation more robust by adding stricter bash settings, clearer fallback behavior, and a more targeted “media only” selection path.
Changes:
- Hardened the bash script with
set -euo pipefailand refactored the empty-feed fallback into a helper. - Updated API calls and selection logic to resolve user ID first, then fetch tweets with media expansions and pick the latest 3 media tweets.
- Adjusted commit messages and “only commit when changed” behavior for
WebSite/assets/x-feed.json.
File summaries
| File | Description |
|---|---|
| .github/workflows/fetch-x-feed.yml | Refactors the feed-fetching workflow’s bash logic, API calls, and fallback/commit behavior for the generated x-feed.json. |
Review details
Suppressed comments (2)
.github/workflows/fetch-x-feed.yml:112
- The workflow commits
WebSite/assets/x-feed.jsonon success, but never pushes the commit. This makes scheduled runs appear successful while not updating the feed in the repository.
if git status --porcelain -- WebSite/assets/x-feed.json | grep -q .; then
git add WebSite/assets/x-feed.json || true
git commit -m "chore: update x media feed" || true
fi
.github/workflows/fetch-x-feed.yml:71
- Same issue for the tweets request:
curl --failcan drop the JSON error body, but the workflow echoes$TWEETS_JSONwhen it can’t fetch tweets. Using--fail-with-bodykeeps the API’s error payload available for troubleshooting.
TWEETS_JSON=$(curl --silent --show-error --fail --location \
-H "Authorization: Bearer $X_BEARER_TOKEN" \
"https://api.twitter.com/2/users/$USER_ID/tweets?max_results=100&expansions=attachments.media_keys&tweet.fields=created_at,attachments&media.fields=preview_image_url,url,type" || true)
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+39
to
+42
| if git status --porcelain -- WebSite/assets/x-feed.json | grep -q .; then | ||
| git add WebSite/assets/x-feed.json || true | ||
| git commit -m "chore: update x media feed (empty fallback)" || true | ||
| fi |
Comment on lines
+56
to
+58
| USER_INFO=$(curl --silent --show-error --fail --location \ | ||
| -H "Authorization: Bearer $X_BEARER_TOKEN" \ | ||
| "https://api.twitter.com/2/users/by/username/$USERNAME" || true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.