Created
May 23, 2024 03:03
-
-
Save PrinOrange/3739941671bc4bec145d93a1256cec32 to your computer and use it in GitHub Desktop.
update npm dependencies (directly)
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 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/[email protected] | |
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