Skip to content

Merge pull request #367 from LeaYeh/ci-job-summary #2

Merge pull request #367 from LeaYeh/ci-job-summary

Merge pull request #367 from LeaYeh/ci-job-summary #2

# .github/workflows/lines_of_code.yaml
name: Lines of Code
on :
push:
branches:
- main
env:
ID : lines_of_code
LABEL : 'lines of code'
LANGUAGES : 'C,C/C++ Header,make,YAML,Python,Bourne Shell,Bourne Again Shell,yacc,Markdown,Dockerfile'
BADGE_COLOR : 61A
_CLOC_DIR : /home/runner/cloc
_LINES_OF_CODE: 0
jobs:
lines_of_code:
name : Lines of Code
runs-on : ubuntu-latest
timeout-minutes: 2
steps :
- name: Checkout branch
uses: actions/checkout@v4
- name: Install cloc
run : |
git clone https://github.com/AlDanial/cloc.git ${{ env._CLOC_DIR }}
- name: 🧮 Count lines by language
run : |
${{ env._CLOC_DIR }}/cloc --fmt=2 --include-lang="${{ env.LANGUAGES }}" . | tee ${{ env._CLOC_DIR }}/cloc_output.txt
echo "_LINES_OF_CODE=$(grep 'SUM' ${{ env._CLOC_DIR }}/cloc_output.txt | awk '{print $5}')" >> "$GITHUB_ENV"
${{ env._CLOC_DIR }}/cloc --md --include-lang="${{ env.LANGUAGES }}" . | tail -n +4 >> $GITHUB_STEP_SUMMARY
- name: 📑 Count lines by file
run : |
${{ env._CLOC_DIR }}/cloc --fmt=5 --include-lang="${{ env.LANGUAGES }}" .
- name: Create badge
uses: RubbaBoy/BYOB@v1
with:
name : "${{ env.ID }}"
label : "${{ env.LABEL }}"
status : "${{ env._LINES_OF_CODE }}"
color : "${{ env.BADGE_COLOR }}"
github_token: "${{ github.token }}"