-
Notifications
You must be signed in to change notification settings - Fork 178
58 lines (51 loc) · 1.95 KB
/
Copy pathupdate-star-history.yml
File metadata and controls
58 lines (51 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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