Skip to content

Commit

Permalink
ci: auto-update kata progress (#478)
Browse files Browse the repository at this point in the history
* ci: auto-update kata progress

* docs: update kata progress
  • Loading branch information
ParanoidUser committed Dec 8, 2023
1 parent befdc97 commit 67953b6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/progress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Update Progress

on:
pull_request:
branches: [ main ]
types: [ opened, synchronize ]
paths:
- .github/workflows/progress.yml
- docs/README.md
- kata/**

jobs:
update-progress:
runs-on: ubuntu-22.04
timeout-minutes: 1
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}

- name: Update README progress
run: |
TOTAL=$(curl https://www.codewars.com/kata/search/java | grep -Eo ".{5} Kata Found" | sed "s/[Kat Found,]//g")
COMPLETED=$(find ./kata -mindepth 2 -maxdepth 2 -not -empty -type d -not -path "./kata/retired/*" | wc -l)
PROGRESS=$(bc <<< "scale=1 ; 100 * $COMPLETED / $TOTAL")
sed -i -r "s/(completed%20kata-).*(%25-red.svg)/\1$PROGRESS\2/g" ./docs/README.md
echo "πŸŽ‰ Current progress $PROGRESS% ($COMPLETED out of $TOTAL)" >> $GITHUB_STEP_SUMMARY
- name: Update README statistics
run: |
STATS="|"
for rank in ./kata/*; do
STATS+=" $(find $rank -mindepth 1 -maxdepth 1 -not -empty -type d | wc -l) |"
done
sed -i "28s/.*/$STATS/" ./docs/README.md
- name: Update Git repository
run: |
git config user.name "$(git log -n 1 --pretty=format:%an)"
git config user.email "$(git log -n 1 --pretty=format:%ae)"
git add -A
if ! git diff-index --quiet HEAD; then
git commit -m "docs: update kata progress"
git push
echo "β˜‘οΈ Codewars progress has been updated." >> $GITHUB_STEP_SUMMARY
else
echo "βœ… Codewars progress is up to date." >> $GITHUB_STEP_SUMMARY
fi
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Codewars Handbook β˜•οΈπŸš€

[![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)
[![Solved kata πŸ‘Œ](https://img.shields.io/badge/solved%20kata-1385-red.svg)](https://www.codewars.com/kata/search/java)
[![Completed kata πŸ‘Œ](https://img.shields.io/badge/completed%20kata-68.6%25-red.svg)](https://www.codewars.com/kata/search/java?xids=completed)
[![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)
[![Quality gate πŸ”Ž](https://img.shields.io/sonar/alert_status/codewars-handbook?server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/dashboard?id=codewars-handbook)
[![Let's have a chat! πŸ“ž](https://img.shields.io/gitter/room/ParanoidUser/codewars-handbook?color=49c39e)](https://gitter.im/ParanoidUser/codewars-handbook)
Expand All @@ -25,7 +25,7 @@ slug.

| [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) |
|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:-----------------------------:|:---------------------------:|:---------------------------------:|
| - | 1 | 2 | 26 | 42 | 416 | 559 | 205 | 55 | 79 |
| 0 | 1 | 2 | 26 | 42 | 416 | 559 | 205 | 55 | 79 |

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

0 comments on commit 67953b6

Please sign in to comment.