Count stars #158
Workflow file for this run
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
name: CI | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
Readme: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: Update readme | |
run: | | |
out="README.md" | |
cat <<-'EOF' > $out | |
# Advent of Code | |
My solutions for the [Advent of Code](https://adventofcode.com), a challenge started by [200,000+](https://adventofcode.com/2023/stats) coders | |
### Progress | |
EOF | |
{ printf "| Day " ; | |
for folder in $("ls" -d */) | |
do | |
printf "|[${folder%/}](https://adventofcode.com/${folder%/})" | |
done | |
echo "|" | |
} >> $out | |
{ printf "| --: " ; | |
for folder in $("ls" -d */) | |
do | |
printf "| :----------: " | |
done | |
echo "|" | |
} >> $out | |
counter=0 | |
for i in $(seq -w 25) | |
do | |
printf "| $i " | |
for folder in $("ls" -d */) | |
do | |
printf "|" | |
compgen -G "$folder$i/first*" >/dev/null && printf ":star": && counter=$(( counter + 1 )) | |
compgen -G "$folder$i/second*" > /dev/null && printf ":star:" && counter=$(( counter + 1 )) | |
done | |
printf "\n" | |
done >> $out | |
echo Total stars: $counter >> $out | |
- name: Commit change | |
uses: EndBug/add-and-commit@v9 | |
with: | |
author_name: agagniere | |
author_email: angagnie@student.42.fr | |
message: "(update readme)" | |
add: README.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |