# Source feed quickstart

Run these commands from the Eritrea 2042 source checkout. The feed can use a dedicated public GitHub repository. Only the files listed below go to that repository. Standard GitHub-hosted runners on public repositories are free.

## 1. Install the workflow and enter the repository secrets

Use a new dedicated repository name or substitute an existing feed repository you control. The following commands create a new feed repository with GitHub Pages enabled.

```bash
gh auth status || gh auth login
gh auth refresh --hostname github.com --scopes workflow
SOURCE_ROOT="$(pwd -P)"
GITHUB_OWNER="$(gh api user --jq .login)"
FEED_REPO="$GITHUB_OWNER/eritrea2042-source-feed"
FEED_CHECKOUT="$(mktemp -d)"
git -C "$SOURCE_ROOT" archive HEAD -- \
  .github/workflows/scrape.yml scripts/fetch_sources.py requirements.txt \
  data/sources.json data/feed.json data/state.json regional-watch.html feed.js feed.css QUICKSTART.md |
  tar -x -C "$FEED_CHECKOUT"
git -C "$FEED_CHECKOUT" init -b main
git -C "$FEED_CHECKOUT" add .
git -C "$FEED_CHECKOUT" commit -m 'Configure Eritrea 2042 source feed'
gh auth setup-git
(cd "$FEED_CHECKOUT" && gh repo create "$FEED_REPO" --public --source=. --remote=origin --push)
gh api --method POST "repos/$FEED_REPO/pages" -f build_type=workflow
gh variable set DEPLOY_FEED_PAGES --repo "$FEED_REPO" --body true
gh secret set AUTH_TOKEN --repo "$FEED_REPO"
gh secret set CT0 --repo "$FEED_REPO"
```

At the two hidden prompts, enter only the values for an X session authorized for this automated use. Session values belong in Actions Secrets. X publishes conditions for automated access, including limits on scripting its website. [X automation rules](https://help.x.com/en/rules-and-policies/x-automation) · [GitHub billing and usage](https://docs.github.com/en/actions/concepts/billing-and-usage)

## 2. Dispatch the sweep

```bash
RUN_SINCE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
gh workflow run scrape.yml --repo "$FEED_REPO" --ref main -f run_mode=full_now
for attempt in $(seq 1 15); do
  RUN_ID="$(gh run list --repo "$FEED_REPO" --workflow scrape.yml --event workflow_dispatch --branch main --created ">=$RUN_SINCE" --limit 1 --json databaseId --jq '.[0].databaseId // empty')"
  if [ -n "$RUN_ID" ]; then break; fi
  sleep 2
done
test -n "$RUN_ID" && gh run watch "$RUN_ID" --repo "$FEED_REPO" --exit-status
```

`full_now` schedules every active source in the workbook catalog and every listed web publisher. Repeating it resumes pending sources from the checkpoint. The cron job rotates through 35 X accounts at a time and polls all web publishers. A platform access error or rate limit can leave sources pending. The run summary and `coverage.pending` show the difference between a finished job and completed coverage.

## 3. Verify the public feed and connect it to the Site

```bash
PAGES_URL="$(gh api "repos/$FEED_REPO/pages" --jq .html_url)"
curl -fsSL "$PAGES_URL" >/dev/null
curl -fsSL "${PAGES_URL%/}/data/sources.json" |
  jq -e '.sources | map(select(.active and .platform == "x")) | length == 412'
curl -fsSL "${PAGES_URL%/}/data/feed.json" |
  jq '{lastSyncedAt,lastCheckedAt,coverage,itemCount:(.items|length)}'
curl -fsSL "${PAGES_URL%/}/data/feed.json" | jq -e '.coverage.pending == 0'
printf '%s\n' "${PAGES_URL%/}/data/feed.json"
```

For automatic refresh on the existing Eritrea 2042 Site, set the following value in its source checkout and publish that Site revision. The browser checks the remote catalog revision and falls back to the local snapshot if the remote feed is unavailable.

```bash
cd "$SOURCE_ROOT"
python3 - "https://raw.githubusercontent.com/$FEED_REPO/refs/heads/main/data/feed.json" <<'PY'
import json, sys
from pathlib import Path
file = Path("data/sources.json")
catalog = json.loads(file.read_text())
catalog["remoteFeedUrl"] = sys.argv[1]
file.write_text(json.dumps(catalog, ensure_ascii=False, indent=2) + "\n")
PY
npm run check:publish
```

- Site routes · [Regional Watch](https://eritrea2042.marinespoon.chatgpt.site/watch/#source-feed) · [News](https://eritrea2042.marinespoon.chatgpt.site/#source-feed)
- The six UI categories preserve the workbook labels in `listedCategory`. Global News & Policy Think Tanks appears under U.S. & Global Diplomacy / Defense / OSINT.
- Publisher pages and profile links remain attributed. The `Official directory` label reflects the catalog classification. A Government label on X reflects platform metadata.
