Skip to content

Commit 67953b6

Browse files
authored
ci: auto-update kata progress (#478)
* ci: auto-update kata progress * docs: update kata progress
1 parent befdc97 commit 67953b6

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Update Progress
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
types: [ opened, synchronize ]
7+
paths:
8+
- .github/workflows/progress.yml
9+
- docs/README.md
10+
- kata/**
11+
12+
jobs:
13+
update-progress:
14+
runs-on: ubuntu-22.04
15+
timeout-minutes: 1
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
19+
with:
20+
fetch-depth: 0
21+
ref: ${{ github.event.pull_request.head.ref }}
22+
23+
- name: Update README progress
24+
run: |
25+
TOTAL=$(curl https://www.codewars.com/kata/search/java | grep -Eo ".{5} Kata Found" | sed "s/[Kat Found,]//g")
26+
COMPLETED=$(find ./kata -mindepth 2 -maxdepth 2 -not -empty -type d -not -path "./kata/retired/*" | wc -l)
27+
PROGRESS=$(bc <<< "scale=1 ; 100 * $COMPLETED / $TOTAL")
28+
sed -i -r "s/(completed%20kata-).*(%25-red.svg)/\1$PROGRESS\2/g" ./docs/README.md
29+
echo "πŸŽ‰ Current progress $PROGRESS% ($COMPLETED out of $TOTAL)" >> $GITHUB_STEP_SUMMARY
30+
31+
- name: Update README statistics
32+
run: |
33+
STATS="|"
34+
for rank in ./kata/*; do
35+
STATS+=" $(find $rank -mindepth 1 -maxdepth 1 -not -empty -type d | wc -l) |"
36+
done
37+
sed -i "28s/.*/$STATS/" ./docs/README.md
38+
39+
- name: Update Git repository
40+
run: |
41+
git config user.name "$(git log -n 1 --pretty=format:%an)"
42+
git config user.email "$(git log -n 1 --pretty=format:%ae)"
43+
git add -A
44+
if ! git diff-index --quiet HEAD; then
45+
git commit -m "docs: update kata progress"
46+
git push
47+
echo "β˜‘οΈ Codewars progress has been updated." >> $GITHUB_STEP_SUMMARY
48+
else
49+
echo "βœ… Codewars progress is up to date." >> $GITHUB_STEP_SUMMARY
50+
fi

β€Ždocs/README.mdβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Codewars Handbook β˜•οΈπŸš€
22

33
[![Views statistics +1 πŸ‘€](https://img.shields.io/badge/dynamic/xml?color=success&label=views&query=//*[name()=%27text%27][3]&url=https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FParanoidUser%2Fcodewars-handbook)](https://hits.seeyoufarm.com/api/count/graph/dailyhits.svg?url=https://github.com/ParanoidUser/codewars-handbook)
4-
[![Solved kata πŸ‘Œ](https://img.shields.io/badge/solved%20kata-1385-red.svg)](https://www.codewars.com/kata/search/java)
4+
[![Completed kata πŸ‘Œ](https://img.shields.io/badge/completed%20kata-68.6%25-red.svg)](https://www.codewars.com/kata/search/java?xids=completed)
55
[![CI pipeline πŸ› ](https://img.shields.io/github/actions/workflow/status/ParanoidUser/codewars-handbook/build.yml?branch=main)](https://github.com/ParanoidUser/codewars-handbook/actions/workflows/build.yml)
66
[![Quality gate πŸ”Ž](https://img.shields.io/sonar/alert_status/codewars-handbook?server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/dashboard?id=codewars-handbook)
77
[![Let's have a chat! πŸ“ž](https://img.shields.io/gitter/room/ParanoidUser/codewars-handbook?color=49c39e)](https://gitter.im/ParanoidUser/codewars-handbook)
@@ -25,7 +25,7 @@ slug.
2525

2626
| [1 kyu](/kata/1-kyu/index.md) | [2 kyu](/kata/2-kyu/index.md) | [3 kyu](/kata/3-kyu/index.md) | [4 kyu](/kata/4-kyu/index.md) | [5 kyu](/kata/5-kyu/index.md) | [6 kyu](/kata/6-kyu/index.md) | [7 kyu](/kata/7-kyu/index.md) | [8 kyu](/kata/8-kyu/index.md) | [beta](/kata/beta/index.md) | [retired](/kata/retired/index.md) |
2727
|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:---------------------------:|:---------------------------------:|
28-
| - | 1 | 2 | 26 | 42 | 416 | 559 | 205 | 55 | 79 |
28+
| 0 | 1 | 2 | 26 | 42 | 416 | 559 | 205 | 55 | 79 |
2929

3030
**Note:** The source code is written in Java 17 and may use language features that are incompatible
3131
with Java 8, 11.

0 commit comments

Comments
Β (0)