From 57f668c175c626e76eaceefd888f0db6b1ae683e Mon Sep 17 00:00:00 2001 From: Brett Logan Date: Mon, 21 Feb 2022 10:04:19 -0500 Subject: [PATCH] Add weekly NPM automation --- .github/scripts/update-npm.sh | 29 +++++++++++++++++++++++++++++ .github/workflows/deps-npm.yml | 16 ++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100755 .github/scripts/update-npm.sh create mode 100644 .github/workflows/deps-npm.yml diff --git a/.github/scripts/update-npm.sh b/.github/scripts/update-npm.sh new file mode 100755 index 00000000..c070449c --- /dev/null +++ b/.github/scripts/update-npm.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Enable strict error checking +set -euo pipefail + +# Install ncu +npm i -g npm-check-updates +pushd dependencies + +# Update all dependencies +ncu -u +npm install + +# Use NPM audit to force fix html-lint issue +npm audit fix --force +npm install + +# Use ncu to force fix NPM audit issue +ncu -u +npm install +popd + +# Push changes to remote +git add . +git commit -a -Ss -m "Update NPM dependencies" +git checkout -b "npm_deps_${id}" +git push origin "npm_deps_${id}" + +# Open pull request +gh pr create --title "Weekly NPM Updates" --body "Updates NPM dependencies" --base master --head "npm_deps_${id}" diff --git a/.github/workflows/deps-npm.yml b/.github/workflows/deps-npm.yml new file mode 100644 index 00000000..cd3972d8 --- /dev/null +++ b/.github/workflows/deps-npm.yml @@ -0,0 +1,16 @@ +name: Update Deps - NPM +on: + schedule: + # Sunday at 5:00pm + - cron: "0 17 * * 0" + workflow_dispatch: +jobs: + update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Update NPM + uses: actions/npm-update@v1 + - run: ./github/scripts/update-npm.sh + env: + id: ${{ github.run_id }}