Skip to content

Update Star History & Contributors #5

Update Star History & Contributors

Update Star History & Contributors #5

name: Update Star History
on:
schedule:
- cron: "17 * * * *"
timezone: "Asia/Shanghai"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: update-star-history
cancel-in-progress: true
jobs:
update:
if: github.repository == 'Stack-Cairn/LiveAgent'
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Download Star History charts
env:
STAR_HISTORY_TOKEN: ${{ secrets.STAR_HISTORY_TOKEN }}
run: |
set -euo pipefail
mkdir -p docs/images
cache_key="$(date -u +%Y-%m-%d-%H)-${GITHUB_RUN_ID}"
base_url="https://api.star-history.com/chart?repos=Stack-Cairn/LiveAgent&type=date&legend=top-left&sealed_token=${STAR_HISTORY_TOKEN}&cache=${cache_key}"
curl --fail --location --retry 3 --retry-all-errors --show-error \
"$base_url" \
--output docs/images/star-history-light.svg
curl --fail --location --retry 3 --retry-all-errors --show-error \
"${base_url}&theme=dark" \
--output docs/images/star-history-dark.svg
grep -q '<svg' docs/images/star-history-light.svg
grep -q '<svg' docs/images/star-history-dark.svg
- name: Check chart files
run: |
set -euo pipefail
test -s docs/images/star-history-light.svg
test -s docs/images/star-history-dark.svg
- name: Commit and push changes
run: |
set -euo pipefail
git add README.md README.zh-CN.md docs/images/star-history-light.svg docs/images/star-history-dark.svg
if git diff --cached --quiet; then
echo "Star History charts are unchanged."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -m "docs: refresh star history chart"
git push