name: Demo on: push: branches: [main] paths-ignore: - "demo/**" - "**.md" - "LICENSE" workflow_dispatch: permissions: contents: write concurrency: group: demo cancel-in-progress: true jobs: generate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: go-version: "1.26" cache: true - name: Build ghstats run: go build -trimpath -ldflags="-s -w" -o ghstats . - name: Render every card for every theme env: GITHUB_TOKEN: ${{ secrets.GHSTATS_TOKEN }} run: | rm -rf demo mkdir -p demo ./ghstats \ -user "${{ github.repository_owner }}" \ -themes all \ -tz Asia/Saigon \ -out demo - name: Write demo README env: OWNER: ${{ github.repository_owner }} REPO: ${{ github.repository }} run: | cards=( profile-details repos-per-language most-commit-language stats productive-time productive-weekday contributions contributions-heatmap top-starred-repos streak most-commit-language-all-time productive-time-all-time productive-weekday-all-time contributions-all-time contributions-by-year ) themes=$(./ghstats -list-themes) { echo "# ghstats demo gallery" echo echo "Every card in every theme, rendered for [\`$OWNER\`](https://github.com/$OWNER)." echo echo "Auto-generated by [\`.github/workflows/demo.yml\`](../.github/workflows/demo.yml) on each push to \`main\`. Do not edit by hand." echo echo "## Themes" echo for theme in $themes; do echo "- [\`$theme\`](#$theme)" done echo for theme in $themes; do dir="demo/$theme" [ -d "$dir" ] || continue echo "## $theme" echo for card in "${cards[@]}"; do svg="$dir/$card.svg" [ -f "$svg" ] || continue echo "![$card](./$theme/$card.svg)" done echo echo "[back to top](#themes)" echo done } > demo/README.md - name: Commit demo back to main run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add demo if git diff --cached --quiet; then echo "No demo changes to commit." exit 0 fi git commit -m "chore(demo): regenerate gallery" git push origin HEAD:${{ github.ref_name }}