Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions .github/workflows/refresh-traffic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,35 +108,26 @@ jobs:
New-Item -ItemType Directory -Force -Path $dir | Out-Null
$snap | ConvertTo-Json -Depth 10 | Set-Content -Encoding UTF8 (Join-Path $dir "_traffic.json")

- name: Create branch, commit, push, and open PR
- name: Create branch, commit, and push
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail

if git diff --quiet data/_traffic.json; then
echo "No changes - skipping."
echo "No changes to data/_traffic.json - nothing to do."
exit 0
fi

BRANCH="chore/traffic-$(date -u +%Y%m%d-%H%M%S)"
BRANCH="chore/traffic-refresh"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Delete old branch if exists, then create fresh
git push origin --delete "$BRANCH" 2>/dev/null || true
git checkout -b "$BRANCH"
git add data/_traffic.json
git commit -m "chore: refresh traffic snapshot $(date -u +%Y-%m-%d)"
git push origin "$BRANCH"

EXISTING_PR=$(gh pr list --state open --search "refresh traffic snapshot in:title" --json number 2>/dev/null | python3 -c "import json,sys; d=json.load(sys.stdin); print(d[0][\"number\"] if d else \"\")" || true)
if [[ -n "$EXISTING_PR" ]]; then
gh pr close "$EXISTING_PR" --comment "Superseded by new refresh." || true
fi

gh pr create \
--title "chore: refresh traffic snapshot $(date -u +%Y-%m-%d)" \
--body "Auto-generated by refresh-traffic workflow. Updates data/_traffic.json with latest GitHub Traffic and NuGet download stats." \
--base main \
--head "$BRANCH"

echo "PR opened from branch $BRANCH"
echo "Pushed to branch $BRANCH - create PR at:"
echo "https://github.com/memoryfraction/Quant.Infra.Net/compare/main...$BRANCH?expand=1"
Loading