This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
Scheduled metrics update #1952
This file contains 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: Scheduled metrics update | |
on: | |
workflow_dispatch: | |
schedule: | |
# Runs at the first minute of every hour (see https://crontab.guru) | |
- cron: "0 * * * *" | |
jobs: | |
typescript-vs-javascript-files: | |
name: Update statistics on JavaScript to TypeScript migration | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout metrics repo (this repo) | |
uses: actions/checkout@v4 | |
with: | |
path: REPOS/metrics | |
- name: Checkout Vitals repo | |
uses: actions/checkout@v4 | |
with: | |
repository: Luscii/cVitals-Web | |
ref: test | |
path: REPOS/vitals | |
token: ${{ secrets.CI_GITHUB_TOKEN }} | |
fetch-depth: 1 | |
- name: Collect metrics | |
shell: bash | |
run: | | |
TS=$(find REPOS/vitals/src -name "*.ts" -o -name "*.tsx" | wc -l | xargs) | |
JS=$(find REPOS/vitals/src -name "*.js" -o -name "*.jsx" | wc -l | xargs) | |
TOTAL=$(expr $TS + $JS) | |
echo "{ \"typescript\": $TS, \"javascript\": $JS, \"total\": $TOTAL }" | jq > REPOS/metrics/typescript-migration.json | |
- name: Commit results | |
shell: bash | |
run: | | |
cd REPOS/metrics | |
git config --global user.email "developer-metrics-automation@no-reply.com" | |
git config --global user.name "Developer Metrics Automation" | |
git add . | |
# Only commit if there are changes | |
git diff-index --quiet HEAD -- || git commit -m "auto-update: Update TypeScript migration statistics" | |
git push |