A Nodejs script to count your daily codes, and it will auto-update daily code stats on your README.md.
You can use this action to your homepage repo, and it will update your README.md every day. Example: Talljack
name: daily-code-stats
on:
schedule:
- cron: '0 0 * * *' # 每天运行一次
jobs:
daily-code-stats:
runs-on: ubuntu-latest
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Daily Codes Stats
uses: Talljack/daily-code-stats@main
env:
token: ${{secrets.GITHUB_TOKEN}} # 使用存储在仓库 Secrets 中的 GitHub 令牌
- name: Commit files
id: commit-files
run: |
if [ -n "$(git status --porcelain README.md)" ]; then
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add README.md
git commit -m "Update README.md"
echo "hasChange=true" >> $GITHUB_OUTPUT
else
echo "No Changes"
fi
- name: Push changes
uses: ad-m/github-push-action@master
if: ${{ steps.commit-files.outputs.hasChange == 'true' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
Usually, you can add this action to your homepage repo, and it will update your README.md every day.
token
- YourGITHUB_TOKEN
. This is required. Why do we need atoken
? Read more here: About the GITHUB_TOKEN secret. Default:${{ github.token }}
dailyCodeInfo
- The daily code info. JSON string. Example:{"username": "Talljack", "2023-12-06": {"additions": 66, "deletions": 66}}
Licensed under the MIT License.
Date | Addition Codes | Deletion Codes |
---|---|---|
2024-04-26 | 3287 | 291 |