Skip to content

Commit

Permalink
feat: add 2023 stars management
Browse files Browse the repository at this point in the history
  • Loading branch information
alanjaouen committed Dec 3, 2023
1 parent de011cc commit c36c325
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/2023.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: update 2023 stars
on:
- push
- workflow_dispatch
jobs:
update-2023-stars:
name: fetch 2023 stars and update README.md
runs-on: ubuntu-latest
env:
leaderboardId: 3575035
userId: 3575035
SESSION_COOKIE: ${{ secrets.SESSION_COOKIE }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
README.md
sparse-checkout-cone-mode: false

- name: fetch 2023 stars
run: |
curl "https://adventofcode.com/2023/leaderboard/private/view/${leaderboardId}.json" \
-H 'Accept: Application/json ' \
-H "Cookie: session=${SESSION_COOKIE}" \
-o 2023.json
- name: update 2023 stars in README.md
run: |
starsCount=$(jq --arg userId "${userId}" -r '.members[$userId].stars' 2023.json)
sed -i "s/\!\[2023\](https:\/\/img\.shields\.io\/badge\/2023-[0-9]\+/\!\[2023\](https:\/\/img\.shields\.io\/badge\/2023-${starsCount}/" README.md
- name: commit and push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add README.md
git commit -m "[no ci] README: update 2023 stars"
git push
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 🎄 Advent of Code🎄

![2023](https://img.shields.io/badge/2023-3%E2%AD%90-green.svg?style=for-the-badge)

## Summary

[Advent of Code](http://adventofcode.com/) is an annual Advent calendar of programming puzzles. This repository houses my solutions to these festive coding challenges, bringing together a collection of creative and efficient approaches to tackle each problem.
Expand Down

0 comments on commit c36c325

Please sign in to comment.