File tree Expand file tree Collapse file tree 2 files changed +56
-1
lines changed Expand file tree Collapse file tree 2 files changed +56
-1
lines changed Original file line number Diff line number Diff line change
1
+ name : Patch Vulnerabilities in Node.js
2
+
3
+ on :
4
+ schedule :
5
+ # Run daily at midnight UTC
6
+ - cron : ' 0 1 * * 0'
7
+ workflow_dispatch :
8
+
9
+ permissions :
10
+ contents : write
11
+ pull-requests : write
12
+ jobs :
13
+ patch-vulnerabilities :
14
+ runs-on : ubuntu-latest
15
+
16
+ steps :
17
+ - uses : actions/checkout@v4
18
+ - name : Set up Node.js
19
+ uses : actions/setup-node@v4
20
+ with :
21
+ node-version : 22
22
+ cache : ' npm'
23
+ - name : Install dependencies
24
+ run : npm ci
25
+
26
+ - name : Run npm audit fix
27
+ run : npm audit fix
28
+
29
+ - name : Commit and push changes
30
+ run : |
31
+ BRANCH_NAME="security-patch-${GITHUB_REF_NAME}-$(date +'%Y-%m-%d')"
32
+ git config user.name "livingdocs-machine"
33
+ git config user.email "[email protected] "
34
+ git checkout -b $BRANCH_NAME
35
+ git add package.json package-lock.json
36
+ if git diff --quiet; then
37
+ echo "No changes to commit."
38
+ exit 0
39
+ fi
40
+ git commit -m "fix(deps): automatically patch Node.js vulnerabilities"
41
+ git push origin $BRANCH_NAME
42
+ env :
43
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
44
+
45
+ - name : Create a pull request
46
+ run : |
47
+ BRANCH_NAME="security-patch-${GITHUB_REF_NAME}-$(date +'%Y-%m-%d')"
48
+ if git ls-remote --exit-code --heads origin $BRANCH_NAME; then
49
+ gh pr create -B $GITHUB_REF_NAME -H $BRANCH_NAME --title "Patch vulnerabilities [$GITHUB_REF_NAME]" --body 'Created by Github action'
50
+ else
51
+ echo "Branch doesn't exist, so PR creation can be skipped."
52
+ exit 0
53
+ fi
54
+ env :
55
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 1
- 16
1
+ 20
You can’t perform that action at this time.
0 commit comments