Skip to content

Commit 9da3df8

Browse files
authored
Rename job and update clone badge workflow
1 parent 0e615e7 commit 9da3df8

File tree

1 file changed

+9
-29
lines changed

1 file changed

+9
-29
lines changed
Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Update clone stats
1+
name: Update clone badges
22

33
on:
44
schedule:
@@ -9,45 +9,25 @@ permissions:
99
contents: write
1010

1111
jobs:
12-
update-clones:
12+
update:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- name: Checkout repo
16-
uses: actions/checkout@v4
15+
- uses: actions/checkout@v4
1716

18-
- name: Get clone stats
17+
- name: Update badges
1918
env:
20-
GH_TOKEN: ${{ secrets.CLONE_STATS_TOKEN }}
19+
TRAFFIC_TOKEN: ${{ secrets.TRAFFIC_TOKEN }}
2120
run: |
22-
OWNER=${GITHUB_REPOSITORY%/*}
23-
REPO=${GITHUB_REPOSITORY#*/}
21+
python3 scripts/update_clones_badges.py
2422
25-
RESPONSE=$(curl -s \
26-
-H "Accept: application/vnd.github+json" \
27-
-H "Authorization: Bearer $GH_TOKEN" \
28-
"https://api.github.com/repos/$OWNER/$REPO/traffic/clones")
29-
30-
export RESPONSE
31-
32-
COUNT=$(python - << 'PY'
33-
import json, os
34-
data = json.loads(os.environ["RESPONSE"])
35-
print(data.get("count", 0))
36-
PY
37-
)
38-
39-
cat > clones.json <<EOF
40-
{"schemaVersion": 1, "label": "clones", "message": "$COUNT"}
41-
EOF
42-
43-
- name: Commit changes
23+
- name: Commit & push if changed
4424
run: |
4525
if [ -z "$(git status --porcelain)" ]; then
4626
echo "No changes."
4727
exit 0
4828
fi
4929
git config user.name "github-actions[bot]"
5030
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
51-
git add clones.json
52-
git commit -m "Update clone stats"
31+
git add .github/traffic/*.json
32+
git commit -m "Update clone badges"
5333
git push

0 commit comments

Comments
 (0)