Update File Every 10 Minutes #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update File Every 10 Minutes | |
on: | |
schedule: | |
- cron: '*/10 * * * *' # 每 10 分钟运行一次 | |
workflow_dispatch: # 支持手动点击触发 | |
jobs: | |
update-file: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout repository content | |
uses: actions/checkout@v3 | |
# Step 2: Set up Node.js 20 environment | |
- name: Set up Node.js 20.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
# Step 3: Install node-fetch or axios (根据你选择的工具) | |
- name: Install dependencies | |
run: npm install axios | |
# Step 4: Download the file and save it with a custom name | |
- name: Download and save the file | |
run: node download-file1.js | |
# Step 5: Check if there are any changes and push to the repository | |
- name: Commit and push changes | |
run: | | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
if [ -n "$(git status --porcelain)" ]; then | |
git add . | |
git commit -m "Update file from external link" | |
git push | |
else | |
echo "No changes to commit" |