Skip to content

Commit 57d5307

Browse files
shenxianpengclaude
andauthored
feat: dogfood the published action on this repo, fix deploy token wiring (#13)
Dogfooding immediately surfaced a real gap: the deploy step pushes with ${GITHUB_TOKEN}, but the action never populated that variable — the Quick Start example only works if the caller happens to export GITHUB_TOKEN themselves. Add a github-token input defaulting to github.token and wire it into the deploy step, so deploy-to-pages works out of the box; callers can still pass a custom token. Add .github/workflows/gitstats.yml: runs the published shenxianpeng/gitstats-action@v1 (test.yml already covers the local checkout) on every push to main plus a weekly refresh, deploying this repository's own report to GitHub Pages. README: top-row badge and the live-example badges now point at our own deployed report; document the github-token input. Claude-Session: https://claude.ai/code/session_01EXwAqUQfggpAAtSeHPQQxy Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 4310b76 commit 57d5307

3 files changed

Lines changed: 40 additions & 3 deletions

File tree

‎.github/workflows/gitstats.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Dogfooding: generate this repository's own gitstats report with the
2+
# published action and deploy it to GitHub Pages. This exercises the real
3+
# released v1 tag (not the local checkout, which test.yml already covers)
4+
# and keeps the badge in our README live.
5+
name: GitStats Report
6+
7+
on:
8+
push:
9+
branches: [main]
10+
schedule:
11+
- cron: '0 3 * * 0' # weekly refresh
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
gitstats:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
22+
with:
23+
fetch-depth: 0
24+
25+
- uses: shenxianpeng/gitstats-action@v1
26+
with:
27+
deploy-to-pages: true
28+
env:
29+
# Redundant once v1 carries the github-token input default,
30+
# but keeps the deploy working with any v1.x.
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎README.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GitStats Action
22

3-
[![Test](https://github.com/shenxianpeng/gitstats-action/actions/workflows/test.yml/badge.svg)](https://github.com/shenxianpeng/gitstats-action/actions/workflows/test.yml) [![GitHub Marketplace](https://img.shields.io/badge/GitHub_Marketplace-gitstats--action-blue.svg)](https://github.com/marketplace/actions/gitstats-action)
3+
[![Test](https://github.com/shenxianpeng/gitstats-action/actions/workflows/test.yml/badge.svg)](https://github.com/shenxianpeng/gitstats-action/actions/workflows/test.yml) [![GitHub Marketplace](https://img.shields.io/badge/GitHub_Marketplace-gitstats--action-blue.svg)](https://github.com/marketplace/actions/gitstats-action) [![GitStats](https://shenxianpeng.github.io/gitstats-action/badge.svg)](https://shenxianpeng.github.io/gitstats-action/)
44

55
A GitHub Action that generates insightful visual reports from Git repositories using [gitstats](https://github.com/shenxianpeng/gitstats).
66

@@ -42,9 +42,9 @@ That's it. One `uses` line, and your report is live on GitHub Pages.
4242

4343
Every report ships with a `badge.svg` deployed right next to it — a shields.io-style badge in the gitstats brand colors showing your repository's **live commit count**. It updates automatically on every deploy.
4444

45-
Live example, served from the [gitstats demo report](https://shenxianpeng.github.io/gitstats/) (click one):
45+
Live example — this repository eats its own dog food: the [gitstats.yml workflow](.github/workflows/gitstats.yml) runs this action on every push, and these badges are served from [our own deployed report](https://shenxianpeng.github.io/gitstats-action/) (click one):
4646

47-
[![GitStats report](https://shenxianpeng.github.io/gitstats/badge.svg)](https://shenxianpeng.github.io/gitstats/) [![GitStats last commit](https://shenxianpeng.github.io/gitstats/badges/last-commit.svg)](https://shenxianpeng.github.io/gitstats/)
47+
[![GitStats report](https://shenxianpeng.github.io/gitstats-action/badge.svg)](https://shenxianpeng.github.io/gitstats-action/) [![GitStats last commit](https://shenxianpeng.github.io/gitstats-action/badges/last-commit.svg)](https://shenxianpeng.github.io/gitstats-action/)
4848

4949
After the workflow runs, open the job summary: it contains ready-to-copy badge markdown for your repository. It looks like this:
5050

@@ -81,6 +81,7 @@ For full shields.io URL-parameter customization (any color, `style=for-the-badge
8181
| `ai-model` | AI model (e.g. `gpt-4o`, `claude-sonnet-4-20250514`) | No | |
8282
| `deploy-to-pages` | Automatically deploy the report to GitHub Pages | No | `false` |
8383
| `deploy-branch` | Branch to deploy to (only used when `deploy-to-pages` is `true`) | No | `gh-pages` |
84+
| `github-token` | Token used to push the report to the deploy branch (only used when `deploy-to-pages` is `true`) | No | `${{ github.token }}` |
8485

8586
## Outputs
8687

‎action.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ inputs:
4141
description: 'Branch to deploy to (only used when deploy-to-pages is true)'
4242
required: false
4343
default: 'gh-pages'
44+
github-token:
45+
description: 'Token used to push the report to the deploy branch (only used when deploy-to-pages is true)'
46+
required: false
47+
default: ${{ github.token }}
4448

4549
outputs:
4650
report_path:
@@ -122,6 +126,7 @@ runs:
122126
env:
123127
REPORT_PATH: ${{ steps.gitstats.outputs.report_path }}
124128
DEPLOY_BRANCH: ${{ inputs.deploy-branch }}
129+
GITHUB_TOKEN: ${{ inputs.github-token }}
125130
run: |
126131
set -e
127132
cd "${REPORT_PATH}"

0 commit comments

Comments
 (0)