-
Notifications
You must be signed in to change notification settings - Fork 43
194 lines (167 loc) · 5.72 KB
/
app-npm-dep-check.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: NPM Dependency Reports
on:
schedule:
- cron: '0 15 * * 2' # Tuesday morning at 7:00-8:00am Pacific Time.
workflow_dispatch:
# START HERE! v
# ADD REQUIRED FILES:
# - .github/helpers/parse-json5-config.js
# - .github/helpers/npm-deps/parse-npm-deps.cjs
# - .github/helpers/npm-deps/create-report.cjs
# - .github/helpers/npm-deps/create-report-issues.cjs
# - .github/helpers/github-api/github-api-requests.cjs
# - .github/helpers/github-api/create-and-close-existing-issue.cjs
# - .github/config/dep-report.json5
# EDIT .github/config/dep-report.json5
# DO NOT Edit below env variables.
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
# Parse Vars from config.
parse-json5-config:
runs-on: ubuntu-22.04
outputs:
# save output from dep-report.json5 to Github env variables
packageJsonPaths: ${{ steps.parse_config.outputs.packageJsonPaths }}
ignoreList: ${{ steps.parse_config.outputs.ignoreList }}
depLevels: ${{ steps.parse_config.outputs.depLevels }}
steps:
# Checkout branch.
- name: Checkout Repository
uses: actions/checkout@v4
# Install json5 npm package for parsing config.
- name: Install Dependencies
run: npm install json5 os
# Run script to convert json5 config to Output Vars.
- name: Run Script
id: parse_config
run: node .github/helpers/parse-json5-config .github/config/dep-report.json5
# Check package versions for updates.
parse-package-versions:
runs-on: ubuntu-22.04
needs: parse-json5-config
env:
packageJsonPaths: ${{ needs.parse-json5-config.outputs.packageJsonPaths }}
container:
# Lightweight NodeJS Image
image: node:21.5-bullseye-slim
steps:
# Checkout branch.
- name: Checkout repository
uses: actions/checkout@v4
# Run NodeJS script to check for latest npm dependency versions and capture output.
- name: Run NPM DEP Check Node.js script
id: check_versions
run: |
node .github/helpers/npm-deps/parse-npm-deps.cjs > outdatedDeps.json
# Upload the output as an artifact.
- name: Upload output
uses: actions/upload-artifact@v4
with:
name: outdatedDeps
path: outdatedDeps.json
# Create comment text
create-comment-text:
runs-on: ubuntu-22.04
needs:
- parse-json5-config
- parse-package-versions
env:
ignoreList: ${{ needs.parse-json5-config.outputs.ignoreList }}
depLevels: ${{ needs.parse-json5-config.outputs.depLevels }}
outputs:
commentContents: ${{ steps.create_comment.outputs.commentContents }}
steps:
# download artifact from parse-package-versions
- name: Download output
uses: actions/download-artifact@v4
with:
name: outdatedDeps
path: .
# encode file to github needs
- name: Encode Outdated Deps
shell: bash
run: |
OUTPUT=$(cat outdatedDeps.json)
OUTPUT="${OUTPUT//'%'/'%25'}"
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
echo "DEP_INPUT=${OUTPUT}" >> $GITHUB_ENV
# checkout repo and branch
- name: Checkout Branch
uses: actions/checkout@v4
# setup Python environment
- name: setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11' # current Python version
# Run Python Script to Create Comment
- name: Create Comment Contents
id: create_comment
env:
DEP_INPUT: ${{ env.DEP_INPUT }} # dependency updates
run: |
python3 .github/helpers/npm-deps/parse_to_comment.py
# Write the output text for the GitHub Issue.
write-output:
needs:
- parse-json5-config
- parse-package-versions
runs-on: ubuntu-22.04
env:
packageJsonPaths: ${{ needs.parse-json5-config.outputs.packageJsonPaths }}
container:
# Lightweight NodeJS Image
image: node:21.5-bullseye-slim
steps:
# Checkout branch.
- name: Checkout repository
uses: actions/checkout@v4
# Download the output artifact from parse-package-versions.
- name: Download output
uses: actions/download-artifact@v4
with:
name: outdatedDeps
path: .
# Run NodeJS script to create GitHub Issue body.
- name: Run NPM DEP Check Node.js script
id: check_versions
run: |
node .github/helpers/npm-deps/create-report.cjs > outputText.json
# Upload the output as an artifact.
- name: Upload output
uses: actions/upload-artifact@v4
with:
name: outputText
path: outputText.json
# Create the GitHub Issues.
create-issues:
needs:
- parse-json5-config
- create-comment-text
- write-output
runs-on: ubuntu-22.04
env:
packageJsonPaths: ${{ needs.parse-json5-config.outputs.packageJsonPaths }}
commentContents: ${{ needs.create-comment-text.outputs.commentContents }}
container:
# Lightweight NodeJS Image
image: node:21.5-bullseye-slim
steps:
# Checkout branch.
- name: Checkout repository
uses: actions/checkout@v4
# Download the output artifact.
- name: Download output
uses: actions/download-artifact@v4
with:
name: outputText
path: .
# Install @octokit/rest npm package for making GitHub rest API requests.
- name: Install @octokit/rest npm
run: npm i @octokit/rest
# Run Node Script to Create GitHub Issue.
- name: Create GitHub Issues
run: |
node .github/helpers/npm-deps/create-report-issues.cjs