Skip to content

Update Node dependencies (daily) #131

Update Node dependencies (daily)

Update Node dependencies (daily) #131

name: Update Node dependencies (daily)
on:
schedule:
- cron: "0 2 * * *"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: update-node-deps
cancel-in-progress: true
jobs:
update-deps:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
persist-credentials: true
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Update dependencies within current major versions
shell: bash
run: |
set -euo pipefail
npx --yes npm-check-updates@latest \
--upgrade \
--target minor
npm install
- name: Install Playwright browsers and system dependencies
run: npx playwright install --with-deps
- name: Run lint
shell: bash
run: |
set -euo pipefail
if npm pkg get scripts.lint | grep -vq '^{}$'; then
npm run lint
else
echo "No lint script is defined; skipping lint."
fi
- name: Run TypeScript type checking
shell: bash
run: |
set -euo pipefail
if npm pkg get scripts.typecheck | grep -vq '^{}$'; then
npm run typecheck
elif [ -f "tsconfig.json" ]; then
npx tsc --noEmit
else
echo "No typecheck script or tsconfig.json was found; skipping."
fi
- name: Run build
shell: bash
run: |
set -euo pipefail
if npm pkg get scripts.build | grep -vq '^{}$'; then
npm run build
else
echo "No build script is defined; skipping build."
fi
- name: Run Playwright tests
run: npx playwright test
- name: Commit and push dependency updates
shell: bash
run: |
set -euo pipefail
git config user.name "agray"
git config user.email "agray@users.noreply.github.com"
git add -- package.json package-lock.json
if git diff --cached --quiet; then
echo "No Node dependency updates were found."
exit 0
fi
echo "Dependency changes:"
git diff --cached --stat
git diff --cached -- package.json
git commit -m "Update Node dependencies"
# The checkout action has already configured authenticated Git access
# using this workflow's GITHUB_TOKEN.
git pull --rebase origin main
git push origin HEAD:main
echo "Node dependency updates were committed and pushed to main."