File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,23 +13,30 @@ jobs:
1313 runs-on : ubuntu-latest
1414 steps :
1515 - uses : actions/checkout@v4
16+ with :
17+ fetch-depth : 0
1618
1719 - name : Count stats
1820 run : |
1921 LOC=$(find . \( -name '*.js' -o -name '*.ts' -o -name '*.jsx' -o -name '*.tsx' -o -name '*.mjs' \) | grep -v node_modules | grep -v '.next' | grep -v dist | grep -v '.min.' | xargs wc -l 2>/dev/null | tail -1 | awk '{print $1}')
2022 TESTS=$(find . \( -name '*.test.*' -o -name '*.spec.*' \) | grep -v node_modules | xargs grep -c 'it(\|test(' 2>/dev/null | awk -F: '{s+=$2} END {print s+0}')
2123 TEST_FILES=$(find . \( -name '*.test.*' -o -name '*.spec.*' \) | grep -v node_modules | wc -l | awk '{print $1}')
24+ COMMITS=$(git rev-list --count HEAD)
25+ CONTRIBUTORS=$(git shortlog -sn HEAD | wc -l | awk '{print $1}')
26+ FIRST_COMMIT=$(git log --reverse --format=%ad --date=short HEAD | head -1)
2227
23- cat > stats.json << EOF
28+ cat > stats.json << INNER
2429 {
2530 "loc": $LOC,
2631 "tests": $TESTS,
2732 "testFiles": $TEST_FILES,
33+ "commits": $COMMITS,
34+ "contributors": $CONTRIBUTORS,
35+ "firstCommit": "$FIRST_COMMIT",
2836 "updatedAt": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
2937 }
30- EOF
38+ INNER
3139
32- # Clean up indentation
3340 sed -i 's/^ //' stats.json
3441 cat stats.json
3542
3845 git config user.name "github-actions[bot]"
3946 git config user.email "github-actions[bot]@users.noreply.github.com"
4047 git add stats.json
41- git diff --cached --quiet && echo "No changes" || git commit -m "chore: update project stats [skip ci]" && git push
48+ git diff --cached --quiet && echo "No changes" || ( git commit -m "chore: update project stats [skip ci]" && git push)
You can’t perform that action at this time.
0 commit comments