NFL News Scraper #25
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: NFL News Scraper | |
| on: | |
| # Run on schedule (every 6 hours) | |
| schedule: | |
| - cron: '0 */6 * * *' # At minute 0 past every 6th hour | |
| # Allow manual trigger | |
| workflow_dispatch: | |
| jobs: | |
| scrape-news: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Required to push changes | |
| actions: write # Required to trigger workflows | |
| id-token: write # Required to mint secrets token | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: website-ts/package-lock.json | |
| - name: Install dependencies | |
| working-directory: website-ts | |
| run: npm ci | |
| - name: Run NFL News Scraper | |
| id: run-scraper | |
| working-directory: website-ts | |
| env: | |
| OPENAI_REFRESH_TOKEN: ${{ secrets.OPENAI_REFRESH_TOKEN }} | |
| run: npx tsx scripts/nfl-scraper/runAll.ts | |
| - uses: qoomon/actions--access-token@v3 | |
| if: ${{ steps.run-scraper.outputs.openai_refresh_token != '' }} | |
| id: secrets-token | |
| with: | |
| permissions: | | |
| secrets: write | |
| - name: Update OPENAI_REFRESH_TOKEN secret | |
| if: ${{ steps.run-scraper.outputs.openai_refresh_token != '' }} | |
| env: | |
| GITHUB_TOKEN: ${{ steps.secrets-token.outputs.token }} | |
| run: >- | |
| gh secret | |
| set "OPENAI_REFRESH_TOKEN" | |
| --body "${{ steps.run-scraper.outputs.openai_refresh_token }}" | |
| --repo "${{ github.repository }}" | |
| - name: Check for changes | |
| id: git-check | |
| working-directory: website-ts | |
| run: | | |
| git add -A | |
| if git diff --staged --quiet; then | |
| echo "changes=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and push changes | |
| if: steps.git-check.outputs.changes == 'true' | |
| working-directory: website-ts | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "NFL News Bot" | |
| git commit -m "🏈 Auto-update: NFL news articles $(date +'%Y-%m-%d %H:%M')" | |
| git push | |
| - name: Trigger CI build | |
| if: steps.git-check.outputs.changes == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'ci.yml', | |
| ref: context.ref, | |
| }) |