Skip to content

NPM Dependency Reports #17

NPM Dependency Reports

NPM Dependency Reports #17

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-npm-deps.js
# - .github/helpers/create-npm-dep-report.js
# - .github/helpers/create-npm-dep-report-issues.js
# - .github/helpers/github-api/github-api-requests.js
# - .github/helpers/github-api/create-and-close-existing-issue.js
# - .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:
packageJsonPaths: ${{ steps.parse_config.outputs.packageJsonPaths }}
ignorePackages: ${{ steps.parse_config.outputs.ignorePackages }}
steps:
# Checkout branch.
- name: Checkout Repository
uses: actions/checkout@v4
# Install json5 npm package for parsing config.
- name: Install Dependencies
run: npm install json5
# 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 }}
ignorePackages: ${{ needs.parse-json5-config.outputs.ignorePackages }}
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/parse-npm-deps.js > outdatedDeps.json
# Upload the output as an artifact.
- name: Upload output
uses: actions/upload-artifact@v3
with:
name: outdatedDeps
path: outdatedDeps.json
# 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@v3
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/create-npm-dep-report.js > outputText.json
# Upload the output as an artifact.
- name: Upload output
uses: actions/upload-artifact@v3
with:
name: outputText
path: outputText.json
# Create the GitHub Issues.
create-issues:
needs:
- parse-json5-config
- write-output
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.
- name: Download output
uses: actions/download-artifact@v3
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/create-npm-dep-report-issues