Skip to content

Generate images.json #312

Generate images.json

Generate images.json #312

name: Generate images.json
on:
schedule:
- cron: "0 */1 * * *" # 每 1 小时运行一次
workflow_dispatch: # 支持手动触发
jobs:
generate-images-json:
runs-on: ubuntu-latest
steps:
# 检出代码
- name: Checkout code
uses: actions/checkout@v3
# 设置 Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
# 安装依赖
- name: Install dependencies
run: npm install
# 生成 images.json
- name: Generate images.json
run: node scripts/generate-json.js
# 提交和推送更改
- name: Commit and push changes
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git clean -fdx # 清理未跟踪文件
if [ -n "$(git status --porcelain images.json)" ]; then
git add images.json
git commit -m "Auto-generate images.json"
git push
else
echo "No changes to commit, skipping commit and push."
fi