Skip to content

Refactor fetch-x-feed workflow for better error handling - #74

Merged
BreadMotion merged 1 commit into
mainfrom
BreadMotion-patch-4
Sep 16, 2026
Merged

BreadMotion merged 1 commit into
mainfrom
BreadMotion-patch-4

Conversation

@BreadMotion

Copy link
Copy Markdown
Owner

No description provided.

Signed-off-by: パン君 <yamazakimotionpg@gmail.com>
@BreadMotion BreadMotion self-assigned this Sep 16, 2026
Copilot AI lite review requested due to automatic review settings September 16, 2026 11:22
@BreadMotion
BreadMotion merged commit e66b029 into main Sep 16, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 pipefail and 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.json on 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 --fail can drop the JSON error body, but the workflow echoes $TWEETS_JSON when it can’t fetch tweets. Using --fail-with-body keeps 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants