Update Feed #5404
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: Update Feed | |
| on: | |
| schedule: | |
| - cron: '0 * * * *' # Run every hour | |
| workflow_dispatch: # Allow manual trigger | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| fetch-rfc: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/${{ github.repository }}:master | |
| credentials: | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # Copy the latest database to the container. | |
| # Because the container is built from the latest src commit, it does not have the latest database. | |
| # Using the old database causes several bugs. | |
| - name: Copy production database | |
| run: cp data/production.db /app/data/production.db | |
| - name: Run crawling and DB update | |
| run: php bin/console rfc:fetch | |
| working-directory: /app | |
| # Git is not available in the container, so this job only uploads the database file. | |
| - name: Upload updated database | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: production-db | |
| path: /app/data/production.db | |
| update-db: | |
| runs-on: ubuntu-latest | |
| needs: fetch-rfc | |
| steps: | |
| - name: Generate a token | |
| id: generate-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ secrets.APP_ID }} | |
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ steps.generate-token.outputs.token }} | |
| persist-credentials: 'true' | |
| - name: Download updated database | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: production-db | |
| path: data/ | |
| - name: Check for actual database changes | |
| id: check_real_changes | |
| run: | | |
| if git diff --quiet data/production.db; then | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Commit and push changes | |
| if: steps.check_real_changes.outputs.has_changes == 'true' | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git add data/production.db | |
| git commit -m "Update RFC database with latest changes" | |
| git push | |
| generate-rfc-feed: | |
| runs-on: ubuntu-latest | |
| needs: update-db | |
| container: | |
| image: ghcr.io/${{ github.repository }}:master | |
| credentials: | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| # When the database is updated, the default ref is older than the latest commit. | |
| ref: master | |
| - name: Copy production database | |
| run: cp data/production.db /app/data/production.db | |
| - name: Generate feed | |
| run: php bin/console rfc:generate-feed -o feed.xml | |
| working-directory: /app | |
| - name: Upload feed | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: rfc-feed | |
| path: /app/feed.xml | |
| deploy-feed: | |
| runs-on: ubuntu-latest | |
| needs: generate-rfc-feed | |
| steps: | |
| - name: Download updated database | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: rfc-feed | |
| path: dist/ | |
| - name: Deploy to Cloudflare Pages | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| command: pages deploy dist --project-name=php-rfc-feed | |