Skip to content

Sync Progress

Sync Progress #59

Workflow file for this run

name: Sync Progress
on: [ workflow_dispatch ]
jobs:
sync-progress:
runs-on: ubuntu-24.04
timeout-minutes: 1
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Sync progress
id: progress
run: |
TOTAL=$(curl https://www.codewars.com/kata/search/java | grep -Eo ".{5} Kata Found" | sed "s/[Kat Found,]//g")
echo "total=$TOTAL" >> $GITHUB_OUTPUT
COMPLETED=$(find ./kata -mindepth 2 -maxdepth 2 -not -empty -type d -not -path "./kata/retired/*" | wc -l)
echo "completed=$COMPLETED" >> $GITHUB_OUTPUT
PERCENT=$(bc <<< "scale=1 ; 100 * $COMPLETED / $TOTAL")
echo "percent=$PERCENT" >> $GITHUB_OUTPUT
echo "πŸŽ‰ Current progress $PERCENT% ($COMPLETED out of $TOTAL)" >> $GITHUB_STEP_SUMMARY
- name: Update progress
env:
PERCENT: ${{ steps.progress.outputs.percent }}
run: |
sed -i -r "s/(completed%20kata-).*(%25-red.svg)/\1$PERCENT\2/g" ./docs/README.md
- name: Update 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: Commit changes
run: |
git add -A
if ! git diff-index --quiet HEAD; then
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
git commit -m "docs: sync progress"
git push
echo "⬆️ Codewars progress has been updated." >> $GITHUB_STEP_SUMMARY
else
echo "βœ… Codewars progress is up to date." >> $GITHUB_STEP_SUMMARY
fi