Skip to content

Update Content JSON #294

Update Content JSON

Update Content JSON #294

name: Update Content JSON
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
push:
branches:
- main
jobs:
update-content:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch repository content
id: fetch-content
run: |
# 获取API数据并保存
curl -sSL -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/MoeFurina/PhiCommunity-Charts-Repo/contents" \
-o content.json
# 简化的变化检测:总是标记为有变化
echo "changes=true" >> $GITHUB_OUTPUT
- name: Commit changes
run: |
# 检查文件是否存在
if [ ! -f content.json ]; then
echo "错误:content.json 未生成"
exit 1
fi
# 配置Git用户
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# 添加并提交文件
git add content.json
# 检查是否有变化可提交
if git diff-index --quiet HEAD --; then
echo "没有变化可提交"
else
git commit -m "chore: auto-update content.json"
git push
fi