Skip to content

Commit 0382f37

Browse files
itallstartedwithaideaJohn Williams
andauthored
fix: sync workflow creates PR instead of pushing directly to main (#3)
Branch protection rules require changes via pull request, but the workflow was doing a direct git push to main — failing every daily run since March 23. Now creates a timestamped branch and opens a PR. Made-with: Cursor Co-authored-by: John Williams <your@email.com>
1 parent 41d5015 commit 0382f37

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

.github/workflows/sync-upstream-docs.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
permissions:
1212
contents: write
13+
pull-requests: write
1314
steps:
1415
- uses: actions/checkout@v4
1516

@@ -19,10 +20,28 @@ jobs:
1920
C7=$(curl -s https://api.github.com/repos/upstash/context7/releases/latest | jq -r '.tag_name // "no-release"')
2021
echo "{ \"context-hub\": \"$CHUB\", \"context7\": \"$C7\", \"updated\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\" }" > docs/upstream-versions.json
2122
22-
- name: Commit if changed
23+
- name: Create PR if changed
24+
env:
25+
GH_TOKEN: ${{ github.token }}
2326
run: |
2427
git config user.name "github-actions[bot]"
2528
git config user.email "github-actions[bot]@users.noreply.github.com"
2629
git add docs/upstream-versions.json
27-
git diff --staged --quiet || git commit -m "chore: sync upstream versions [automated]"
28-
git push
30+
if git diff --staged --quiet; then
31+
echo "No changes detected — upstream versions unchanged."
32+
exit 0
33+
fi
34+
BRANCH="chore/sync-upstream-$(date +%Y%m%d)"
35+
git checkout -b "$BRANCH"
36+
git commit -m "chore: sync upstream versions [automated]"
37+
git push origin "$BRANCH"
38+
EXISTING=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number')
39+
if [ -z "$EXISTING" ]; then
40+
gh pr create \
41+
--title "chore: sync upstream versions [automated]" \
42+
--body "Automated daily sync of upstream release versions. Auto-generated by the Sync Upstream Doc Sources workflow." \
43+
--head "$BRANCH" \
44+
--base main
45+
else
46+
echo "PR #$EXISTING already exists for this branch."
47+
fi

0 commit comments

Comments
 (0)