lint/.github/scripts/update-npm.sh

40 lines
1 KiB
Bash
Raw Normal View History

2022-02-21 10:04:19 -05:00
#!/usr/bin/env bash
# Enable strict error checking
set -euo pipefail
# Install ncu
npm i -g npm-check-updates
pushd dependencies
# Update all dependencies
2022-02-21 10:50:54 -05:00
echo "Installing NPM dependencies..."
npm install
echo "Updating NPM dependencies..."
2022-02-21 10:04:19 -05:00
ncu -u
2022-02-21 10:50:54 -05:00
echo "Installing NPM dependencies..."
2022-02-21 10:04:19 -05:00
npm install
2022-02-21 10:41:04 -05:00
# Setup Git Config
2022-02-21 10:50:54 -05:00
echo "Configuring Git..."
2022-02-21 10:41:04 -05:00
git config --global user.email "noreply@github.com"
git config --global user.name "Super-Linter Automation"
2022-02-21 11:16:27 -05:00
if [[ $(git status --porcelain) ]]; then
# Push changes to remote
echo "Pushing changes to remote..."
git add .
2022-02-22 10:26:50 -05:00
git commit -a -m "Update NPM dependencies"
2022-02-21 11:52:37 -05:00
# shellcheck disable=SC2154
2022-02-21 11:16:27 -05:00
git checkout -b "npm_deps_${id}"
2022-02-21 11:52:37 -05:00
# shellcheck disable=SC2154
2022-02-21 11:16:27 -05:00
git push origin "npm_deps_${id}"
2022-02-21 10:04:19 -05:00
2022-02-21 11:16:27 -05:00
# Open pull request
echo "Opening pull request..."
2022-02-22 10:34:16 -05:00
# shellcheck disable=SC2154
2022-02-22 10:33:03 -05:00
echo "${token}" | gh auth login --with-token
2022-02-22 10:36:08 -05:00
gh pr create --title "Weekly NPM Updates" --body "Updates NPM dependencies" --base main --head "npm_deps_${id}"
2022-02-21 11:16:27 -05:00
else
echo "No changes to commit"
fi