Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Upgrade NPM packages #53

Upgrade NPM packages

Upgrade NPM packages #53

#https://michaelcurrin.github.io/code-cookbook/recipes/ci-cd/github-actions/workflows/node/upgrade-packages.html
# See tutorial:
# https://michaelcurrin.github.io/code-cookbook/recipes/ci-cd/github-actions/workflows/node/upgrade-packages.html
name: Upgrade NPM packages
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
jobs:
upgrade-packages:
name: Upgrade packages
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
- name: Set up Node.js ⚙️
uses: actions/setup-node@v2
with:
node-version: '16.x'
cache: 'npm'
- name: Check for outdated packages 🔍
id: vars
run: |
OUTDATED=$(yarn outdated) || true
if [[ -z "$OUTDATED" ]]; then
echo 'Nothing to upgrade'
else
echo 'Found outdated packages:'
echo "$OUTDATED"
fi
echo "::set-output name=outdated::$OUTDATED"
- name: Upgrade packages ⏫
if: ${{ steps.vars.outputs.outdated != '' }}
run: npm upgrade
- name: Commit and create PR 🔀
if: ${{ steps.vars.outputs.outdated != '' }}
uses: peter-evans/create-pull-request@v3
with:
title: 'build(deps): Upgrade NPM packages (automated)'
branch: 'build-deps-upgrade-npm-packages-automated'
commit-message: 'build(deps): upgrade NPM packages (automated)'