-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (29 loc) · 1.02 KB
/
update-badge.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: Update Lines of Code Badge
on:
push:
branches:
- main
permissions:
contents: write
jobs:
update-badge:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Count lines of code
id: count_lines
run: |
lines=$(find . -name '*.py' -or -name '*.js' -or -name '*.java' -or -name '*.cpp' -or -name '*.c' -or -name '*.go' -or -name '*.rb' | xargs wc -l | tail -n 1 | awk '{print $1}')
echo "lines=$lines" >> $GITHUB_ENV
- name: Update README.md
run: |
badge="![Lines of Code](https://img.shields.io/badge/lines%20of%20code-${{ env.lines }}-blue)"
sed -i "s|!\[Lines of Code\].*|$badge|" README.md
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add README.md
git commit -m "Update lines of code badge" || echo "No changes to commit"
git push