From 0442c0ef6a4db6c3fb78a826ffb34e22f520a135 Mon Sep 17 00:00:00 2001 From: RTAkland Date: Thu, 26 Sep 2024 05:27:03 +0800 Subject: [PATCH] ci: add cloc --- .github/workflows/code-stats.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/code-stats.yml diff --git a/.github/workflows/code-stats.yml b/.github/workflows/code-stats.yml new file mode 100644 index 0000000..8615c3d --- /dev/null +++ b/.github/workflows/code-stats.yml @@ -0,0 +1,27 @@ +name: Count Lines of Code + +on: + push: + branches: + - main +jobs: + count-loc: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v3 + - name: Install cloc + run: sudo apt-get install -y cloc + - name: Count lines of code + id: cloc + run: | + cloc --json . > cloc.json + - name: Add cloc output to summary + run: | + lines=$(jq '.SUM.code' cloc.json) # 提取代码行数 + echo "# Code Statistics" >> $GITHUB_STEP_SUMMARY + echo "Total lines of code: $lines" >> $GITHUB_STEP_SUMMARY + echo "```json" >> $GITHUB_STEP_SUMMARY + cat cloc.json >> $GITHUB_STEP_SUMMARY + echo "```" >> $GITHUB_STEP_SUMMARY