Skip to content

Commit 3284301

Browse files
Create update-stats.yaml
a chron action that update stats every day
1 parent 3b4483d commit 3284301

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

.github/workflows/update-stats.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Update Stats
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Runs every day at midnight UTC
6+
workflow_dispatch: # Allows manual triggering
7+
8+
permissions:
9+
contents: write # Required to push updates to gh-pages
10+
11+
jobs:
12+
update-stats:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Run stats script
20+
env:
21+
STEAM_ID: ${{ secrets.STEAM_ID }}
22+
STEAM_API_KEY: ${{ secrets.STEAM_API_KEY }}
23+
DISCORD_ID: ${{ secrets.DISCORD_ID }}
24+
DISCORD_BOT_KEY: ${{ secrets.DISCORD_BOT_KEY }}
25+
GIT_API_KEY: ${{ secrets.GIT_API_KEY }}
26+
run: |
27+
chmod +x setup-stats.sh
28+
./setup-stats.sh
29+
30+
- name: Checkout gh-pages branch
31+
uses: actions/checkout@v4
32+
with:
33+
ref: gh-pages
34+
path: gh-pages
35+
36+
- name: Copy stats file to gh-pages
37+
run: |
38+
mv stats.json gh-pages/src/assets/stats.json
39+
cd gh-pages
40+
git config --global user.name "github-actions[bot]"
41+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
42+
git add src/assets/stats.json
43+
git commit -m "Update stats.json" || echo "No changes to commit"
44+
git push

0 commit comments

Comments
 (0)