Skip to content

NPM Dependency Reports #49

NPM Dependency Reports

NPM Dependency Reports #49

name: App NPM Dependency Updates
on:
schedule:
- cron: '0 16 * * 2' # Every Tuesday at 8:00-9:00am Pacific Time.
workflow_dispatch:
# START HERE! v
# THE ONLY EDITING NEEDED IN THIS FILE IS THE ENV VARS BELOW.
# By default, PATH_TO_PACKAGE_JSON is root level.
env:
PATH_TO_PACKAGE_JSON: 'frontend' # Directory of package.json relative to root.
ISSUE_TITLE: 'Frontend NPM Dependency Updates' # Title of Issue displayed in Issues tab in GitHub.
jobs:
check-versions:
runs-on: ubuntu-22.04
container:
# Lightweight NodeJS Image - v20.2.x
image: node:20.2-bullseye-slim
steps:
# Checkout branch.
- name: Checkout repository
uses: actions/checkout@v3
# Run NodeJS script to check for latest npm dependency versions and capture output.
- name: Run NPM DEP Check Node.js script
id: check_versions
env:
PACKAGE_JSON: ${{ env.PATH_TO_PACKAGE_JSON }}
run: |
node .github/helpers/check-npm-dependencies.js > output.txt
# Upload the output as an artifact.
- name: Upload output
uses: actions/upload-artifact@v3
with:
name: output
path: output.txt
create-issue:
needs: check-versions
runs-on: ubuntu-22.04
container:
# Lightweight NodeJS Image - v20.2.x
image: node:20.2-bullseye-slim
steps:
# Download the output artifact.
- name: Download output
uses: actions/download-artifact@v3
with:
name: output
path: .
# Encode and set ISSUE_BODY env.
- name: Set ISSUE_BODY env
shell: bash
run: |
OUTPUT=$(cat output.txt)
OUTPUT="${OUTPUT//'%'/'%25'}"
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
echo "ISSUE_BODY=${OUTPUT}" >> $GITHUB_ENV
# Checkout branch.
- name: Checkout repository
uses: actions/checkout@v3
# 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 Issue
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_TITLE: ${{ env.ISSUE_TITLE }}
ISSUE_BODY: ${{ env.ISSUE_BODY }}
PATH_TO_PACKAGE_JSON: ${{ env.PATH_TO_PACKAGE_JSON }}
run: |
node .github/helpers/github-api/create-and-close-existing-issue.js
create-tickets:
needs: check-versions
runs-on: ubuntu-latest
steps:
# Download the output artifact.
- name: Download output
uses: actions/download-artifact@v3
with:
name: output
path: .
# Encode and set ISSUE_BODY env.
- name: Set ISSUE_BODY env
shell: bash
run: |
OUTPUT=$(cat output.txt)
echo "ISSUE_BODY=${OUTPUT}" >> $GITHUB_ENV
# Checkout branch
- name: Checkout repository
uses: actions/checkout@v3
# Setup Python
- name: setup python
uses: actions/setup-python@v4
with:
python-version: '3.11' # current Python version
- name: execute py script
env:
JIRA_API_KEY: ${{ secrets.JIRA_API_KEY }}
ISSUE_BODY: ${{ env.ISSUE_BODY }}
run: |
python3 scripts/create_tickets.py