CWV Stats Monthly #3
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: CWV Stats Monthly | |
| on: | |
| # http archive crawl usually starts on the 2nd Tuesday of the month and finishes within ~2weeks usually by the 1st | |
| # of the following month therefore we run the crawl on the 7th to give a full weeks buffer after the crawl finishes. | |
| # https://har.fyi/guides/release-cycle/#running-the-crawl | |
| schedule: | |
| - cron: '0 0 7 * *' # At 00:00 on day-of-month 7 (UTC) | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| run-cwv-stats: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Build cwv-stats image | |
| run: docker build . --target cwv-stats -t cwv-stats | |
| - name: Run cwv-stats container | |
| run: | | |
| container_id=$(docker run -d cwv-stats) | |
| docker wait "$container_id" | |
| docker cp "$container_id:/app/cwv-stats.json" ./packages/docs/src/content/cwv/cwv-stats.json | |
| cat ./packages/cwv-stats/cwv-stats.json | |
| docker rm "$container_id" | |
| - name: Create Pull Request | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| if [[ -z $(git status -s) ]]; then | |
| echo "No changes to commit" | |
| exit 0 | |
| fi | |
| git checkout -B cwv-stats-update | |
| git add packages/ | |
| git commit -m "Update CWV stats and generated stats" | |
| git push --force-with-lease origin cwv-stats-update | |
| if ! gh pr list --head cwv-stats-update --state open | grep -q .; then | |
| gh pr create \ | |
| --title "Update CWV stats and generated stats" \ | |
| --body "Automated CWV stats update triggered by monthly job. | |
| Includes: | |
| - CWV stats for frameworks in packages/cwv-stats/src/frameworks/frameworks.ts | |
| - Outputs stats to packages/cwv-stats/cwv-stats.json | |
| This PR was automatically created and will auto-merge if all checks pass." \ | |
| --base main \ | |
| --head cwv-stats-update | |
| else | |
| echo "PR already exists, updated with new commits" | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |