Skip to content

Sync Upstream Doc Sources #32

Sync Upstream Doc Sources

Sync Upstream Doc Sources #32

name: Sync Upstream Doc Sources
on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Check upstream repos for new releases
run: |
CHUB=$(curl -s https://api.github.com/repos/andrewyng/context-hub/releases/latest | jq -r '.tag_name // "no-release"')
C7=$(curl -s https://api.github.com/repos/upstash/context7/releases/latest | jq -r '.tag_name // "no-release"')
echo "{ \"context-hub\": \"$CHUB\", \"context7\": \"$C7\", \"updated\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\" }" > docs/upstream-versions.json
- name: Create PR if changed
env:
GH_TOKEN: ${{ github.token }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/upstream-versions.json
if git diff --staged --quiet; then
echo "No changes detected — upstream versions unchanged."
exit 0
fi
BRANCH="chore/sync-upstream-$(date +%Y%m%d)"
git checkout -b "$BRANCH"
git commit -m "chore: sync upstream versions [automated]"
git push origin "$BRANCH"
EXISTING=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number')
if [ -z "$EXISTING" ]; then
gh pr create \
--title "chore: sync upstream versions [automated]" \
--body "Automated daily sync of upstream release versions. Auto-generated by the Sync Upstream Doc Sources workflow." \
--head "$BRANCH" \
--base main
else
echo "PR #$EXISTING already exists for this branch."
fi