Skip to content

Commit

Permalink
ci: sync steam profile data
Browse files Browse the repository at this point in the history
  • Loading branch information
eallion committed Mar 20, 2024
1 parent 7295e97 commit e8c3268
Show file tree
Hide file tree
Showing 5 changed files with 1,358 additions and 20 deletions.
52 changes: 33 additions & 19 deletions .github/workflows/sync-steam-web-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,44 @@ jobs:
echo "WORK_DIR=$(pwd)" >> $GITHUB_ENV
# 获取本地现有文件中最新的 Count
- name: Get Local Current Count
- name: Get Local Current MD5
run: |
CURRENT_COUNT() {
jq '.response.game_count' data/steam/steam_web_api.json
}
echo "CURRENT_COUNT=$(CURRENT_COUNT)" >> $GITHUB_ENV
rm data/steam/steam_web_api.json
LOCAL_MD5=$(md5sum data/steam/steam_web_api.json | cut -d ' ' -f 1)
echo "LOCAL_MD5=$LOCAL_MD5" >> $GITHUB_ENV
rm data/steam/*.json
# 获取远程最新的 Count
- name: Get Steam Latest Count
- name: Get Steam Latest OwnedGames
run: |
curl -X 'GET' \
'https://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=${{ secrets.STEAM_WEB_API_KEY }}&steamid=76561197989210276&format=json' \
-H 'accept: application/json' > data/steam/steam_web_api.json
'https://api.steampowered.com/IPlayerService/GetOwnedGames/v1/?key=${{ secrets.STEAM_WEB_API_KEY }}&steamid=76561197989210276&include_appinfo=true&include_played_free_games=true&format=json' \
-H 'accept: application/json' > data/steam/owned_games.json
REMOTE_COUNT() {
jq '.response.game_count' data/steam/steam_web_api.json
}
echo "REMOTE_COUNT=$(REMOTE_COUNT)" >> $GITHUB_ENV
- name: Fetch Steam Badges
run: |
curl -X 'GET' \
'https://api.steampowered.com/IPlayerService/GetBadges/v1/?key=${{ secrets.STEAM_WEB_API_KEY }}&steamid=76561197989210276&format=json' \
-H 'accept: application/json' > data/steam/badges.json
- name: Fetch Steam Player Summaries
run: |
curl -X 'GET' \
'https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=${{ secrets.STEAM_WEB_API_KEY }}&steamids=76561197989210276&format=json' \
-H 'accept: application/json' > data/steam/player.json
- name: Merge JSON Files
run: |
cd data/steam
jq -s 'reduce .[] as $item ({}; . * $item)' *.json > steam_web_api.json
cd ../..
CURRENT_MD5=$(md5sum data/steam/steam_web_api.json | cut -d ' ' -f 1)
echo "CURRENT_MD5=$CURRENT_MD5" >> $GITHUB_ENV
# 对比 COUNT
- name: UUID Compare
# 对比 MD5
- name: MD5 Compare
run: |
if [ ${{ env.REMOTE_COUNT }} != ${{ env.CURRENT_COUNT }} ]; then
if [ ${{ env.CURRENT_MD5 }} != ${{ env.LOCAL_MD5 }} ]; then
echo "Variables are not equal. Running the next steps."
else
echo "Variables are equal. Skipping the next steps."
Expand All @@ -65,18 +79,18 @@ jobs:
# 把修改后的数据提交到 GitHub 仓库
- name: Git Add and Commit
if: ${{ env.REMOTE_COUNT != env.CURRENT_COUNT }}
if: ${{ env.CURRENT_MD5 != env.LOCAL_MD5 }}
uses: EndBug/add-and-commit@v9
with:
message: 'chore(data): update steam data'
committer_name: 'github-actions[bot]'
committer_email: 'github-actions[bot]@users.noreply.github.com'
add: |
'./data/steam/steam_web_api.json'
'./data/steam'
# # 调用另外的 GitHub Actions 构建 Hugo
- name: Build Hugo and Deploy
if: ${{ env.REMOTE_COUNT != env.CURRENT_COUNT }}
if: ${{ env.CURRENT_MD5 != env.LOCAL_MD5 }}
uses: peter-evans/repository-dispatch@v2
with:
event-type: build-hugo
1 change: 1 addition & 0 deletions data/steam/badges.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"response":{"badges":[{"badgeid":13,"level":124,"completion_time":1709139849,"xp":353,"scarcity":11023386},{"badgeid":66,"level":1,"completion_time":1703183460,"xp":50,"scarcity":32960888},{"badgeid":64,"level":1,"completion_time":1678852971,"xp":50,"scarcity":75037857},{"badgeid":2,"level":3,"completion_time":1534584002,"xp":500,"scarcity":9861525},{"badgeid":1,"level":16,"completion_time":1175761888,"xp":800,"scarcity":8428226},{"badgeid":1,"appid":439190,"level":1,"completion_time":1534583526,"xp":100,"communityitemid":"8838417276","border_color":0,"scarcity":86464}],"player_xp":1853,"player_level":14,"player_xp_needed_to_level_up":147,"player_xp_needed_current_level":1800}}
1 change: 1 addition & 0 deletions data/steam/owned_games.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions data/steam/player.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"response":{"players":[{"steamid":"76561197989210276","communityvisibilitystate":3,"profilestate":1,"personaname":"eallion","commentpermission":1,"profileurl":"https://steamcommunity.com/id/eallion/","avatar":"https://avatars.steamstatic.com/54d22c4e7be1b79620240392cc0fcaab042e4578.jpg","avatarmedium":"https://avatars.steamstatic.com/54d22c4e7be1b79620240392cc0fcaab042e4578_medium.jpg","avatarfull":"https://avatars.steamstatic.com/54d22c4e7be1b79620240392cc0fcaab042e4578_full.jpg","avatarhash":"54d22c4e7be1b79620240392cc0fcaab042e4578","lastlogoff":1710681650,"personastate":0,"realname":"Charles Chin","primaryclanid":"103582791433612637","timecreated":1175761888,"personastateflags":0,"loccountrycode":"US","locstatecode":"CA","loccityid":387}]}}
Loading

0 comments on commit e8c3268

Please sign in to comment.