Skip to content

Instantly share code, notes, and snippets.

@PrinOrange
Created May 23, 2024 03:03
Show Gist options
  • Save PrinOrange/3739941671bc4bec145d93a1256cec32 to your computer and use it in GitHub Desktop.
Save PrinOrange/3739941671bc4bec145d93a1256cec32 to your computer and use it in GitHub Desktop.
update npm dependencies (directly)
name: Update Dependencies
on:
schedule:
# 每周一凌晨 2 点运行
- cron: '0 2 * * MON'
workflow_dispatch: # 允许手动触发
jobs:
update-dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16' # 这里可以设置你需要的 Node.js 版本
- name: Install npm dependencies
run: npm install
- name: Update npm dependencies
run: npm update
- name: Commit updated dependencies
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add package-lock.json package.json
git commit -m 'chore: weekly npm dependencies update' || echo "No changes to commit"
- name: Push changes
uses: ad-m/github-push-action@v0.6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main # 确保与目标分支一致
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment