Skip to content

Update Package Downloads #9

Update Package Downloads

Update Package Downloads #9

---
name: Update Package Downloads
on:
schedule:
# Run every Sunday at 11:59 PM UTC
- cron: "59 23 * * 0"
workflow_dispatch: # Allow manual triggering
jobs:
generate-downloads:
name: Generate package download counts
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
steps:
- uses: actions/checkout@v5
- name: Set up Python 3.13 + uv
uses: "./.github/actions/uv_setup"
with:
python-version: "3.13"
- name: Install dependencies
run: |
uv sync --group test
- name: Update download counts
run: |
# Note: Script only updates packages if their downloads_updated_at
# timestamp is older than 24 hours to avoid hammering pepy.tech.
# If run manually within 24 hours of a previous update, no changes
# will be detected and the workflow will exit early.
uv run scripts/packages_yml_get_downloads.py
- name: Generate partner package table
run: |
uv run python pipeline/tools/partner_pkg_table.py
- name: Upload updated files as artifact
uses: actions/upload-artifact@v4
with:
name: packages-yml
path: |
reference/packages.yml
src/oss/python/integrations/providers/overview.mdx
retention-days: 1
commit-downloads:
name: Create PR with updated download counts
needs: generate-downloads
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v5
- name: Download updated files
uses: actions/download-artifact@v4
with:
name: packages-yml
path: .
- name: Create PR with changes
env:
GH_TOKEN: ${{ github.token }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Check if there are changes
if git diff --quiet reference/packages.yml src/oss/python/integrations/providers/overview.mdx; then
echo "No changes to commit"
exit 0
fi
# Create a new branch with timestamp
BRANCH_NAME="chore/update-package-downloads-$(date +%Y%m%d-%H%M%S)"
git checkout -b "$BRANCH_NAME"
# Commit changes
git add reference/packages.yml src/oss/python/integrations/providers/overview.mdx
git commit -m "$(cat <<'EOF'
chore: update package download counts
πŸ€– Automated update of package download statistics from pepy.tech
and regenerated provider overview page
Generated with GitHub Actions workflow update-package-downloads.yml
EOF
)"
# Push branch
git push origin "$BRANCH_NAME"
# Create PR
gh pr create \
--title "chore: update package download counts" \
--body "$(cat <<'EOF'
## Summary
Automated update of package download statistics from pepy.tech
## Details
- Updates download counts in `reference/packages.yml`
- Regenerates provider overview page at `src/oss/python/integrations/providers/overview.mdx`
- Generated by GitHub Actions workflow `update-package-downloads.yml`
- Scheduled to run every Sunday at 11:59 PM UTC
πŸ€– This PR was created automatically by GitHub Actions
EOF
)" \
--base main \
--head "$BRANCH_NAME"
# Enable auto-merge with squash
gh pr merge "$BRANCH_NAME" --auto --squash