Merge pull request #386 from LeaYeh/fix-issue-257 #23
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
# .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 }}" |