-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (45 loc) · 1.48 KB
/
npm-update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Weekly npm update
on:
schedule:
- cron: "0 0 * * 0" # Run every Sunday at midnight UTC
workflow_dispatch: # Enable manual triggering of the workflow
permissions:
contents: write
issues: write
jobs:
update-dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "latest"
- name: Update dependencies
run: |
npm update && npm update --save-dev && npm update --save
continue-on-error: true
- name: Check for changes
id: git-check
run: |
git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT
- name: Commit and push if changes
if: steps.git-check.outputs.changes == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
git commit -m "chore: update npm dependencies"
git push
- name: Create issue if update fails
if: failure()
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'npm update failed',
body: 'The weekly npm update job failed. Please check the action logs for more details.'
})