Fetch Trending Repositories #32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Fetch Trending Repositories | |
| on: | |
| schedule: | |
| - cron: '0 */24 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| fetch-and-update: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: pip install -r scripts/requirements.txt | |
| - name: Fetch trending repositories | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: python scripts/fetch_trending.py | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if git status --porcelain cached-data/ | grep .; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and push to main | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add cached-data/ | |
| git commit -m "Update trending repositories ($(date -u +'%Y-%m-%d %H:%M:%S UTC'))" | |
| git push origin main | |
| - name: No changes detected | |
| if: steps.changes.outputs.changed == 'false' | |
| run: echo "No changes in trending repositories" |