Daily Update Meta #274
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: Daily Update Meta | |
| on: | |
| schedule: | |
| # Run daily at 2 AM UTC | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| update-meta: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| issues: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Update web-features | |
| run: npm update web-features | |
| - name: Prepare futures data | |
| id: prepare_futures | |
| run: npm run prepare:futures | |
| - name: Extract metadata | |
| id: extract_meta | |
| run: npm run update:meta | |
| - name: Build static site | |
| id: build_site | |
| run: | | |
| node scripts/build.js | |
| node scripts/build-bcd.js | |
| - name: Run unit tests | |
| id: run_tests | |
| run: npm test | |
| - name: Commit and push changes | |
| run: | | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| # Add all changes (tracked and untracked) | |
| git add . | |
| # Check if there are any changes to commit | |
| if ! git diff --cached --quiet; then | |
| echo "✅ Changes detected, committing and pushing to main" | |
| git commit -m "chore: Daily update metadata" -m "Generated by daily GitHub Actions workflow" | |
| git push origin main | |
| else | |
| echo "ℹ️ No changes detected, nothing to commit" | |
| fi | |
| - name: Open Issue on Failure | |
| if: failure() | |
| run: | | |
| # Check if an open issue already exists for the same title | |
| OPEN_ISSUES=$(gh issue list --search "title:\"🔴 Daily Update Pipeline Failed\"" --state open) | |
| if [ -n "$OPEN_ISSUES" ]; then | |
| echo "ℹ️ An open issue already exists, skipping creation..." | |
| else | |
| REASON="An unknown error occurred in the daily update pipeline." | |
| if [ "${{ steps.prepare_futures.outcome }}" == "failure" ]; then | |
| REASON="The web-features preparation / patching failed. This likely means the upstream code has changed and our patcher needs manual update." | |
| elif [ "${{ steps.extract_meta.outcome }}" == "failure" ]; then | |
| REASON="The metadata extraction (data manipulation) failed." | |
| elif [ "${{ steps.build_site.outcome }}" == "failure" ]; then | |
| REASON="The static site build (docs generation) failed." | |
| elif [ "${{ steps.run_tests.outcome }}" == "failure" ]; then | |
| REASON="Unit tests failed." | |
| fi | |
| echo "Creating issue..." | |
| gh issue create \ | |
| --title "🔴 Daily Update Pipeline Failed" \ | |
| --body "$REASON Check the Actions logs for details." \ | |
| --label "bug" || echo "❌ Failed to create issue" | |
| fi | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |