update-dependencies #443
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: update-dependencies | |
on: | |
schedule: | |
- cron: "47 4 * * *" | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3 | |
- name: Setup nodejs version | |
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3 | |
with: | |
node-version-file: ".node-version" | |
- name: Install dependencies | |
run: npm ci | |
- name: Apply updates | |
run: npm run update | |
- name: Check for modified files | |
id: gitCheck | |
run: | | |
echo "diff=$(git diff -U0 package.json | grep -e '^+ ' | awk '{ print $2 }' | sed 's/[\":]//g' | xargs | sed -e 's/ / + /g')" >>$GITHUB_OUTPUT | |
if [ -n "$(git status --porcelain)" ]; then | |
echo "modified=true" >> $GITHUB_OUTPUT | |
else | |
echo "modified=false" >> $GITHUB_OUTPUT | |
fi | |
cat $GITHUB_OUTPUT | |
- name: Update package-lock | |
id: update-package-lock | |
if: steps.gitCheck.outputs.modified == 'true' | |
run: | | |
npm install | |
- name: Create Pull Request | |
id: createPR | |
if: steps.gitCheck.outputs.modified == 'true' | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
branch: update-dependencies | |
author: Dependency Updater <dependency-updater@users.noreply.github.com> | |
commit-message: "chore: update dependencies for ${{steps.gitCheck.outputs.diff}}" | |
title: Update dependencies | |
body: | | |
- Dependency updates | |
Auto-generated by [create-pull-request][1] | |
[1]: https://github.com/peter-evans/create-pull-request | |
delete-branch: true | |
labels: automated pr | |
- name: Enable auth-merge | |
if: steps.gitCheck.outputs.modified == 'true' | |
uses: peter-evans/enable-pull-request-automerge@v3 | |
with: | |
pull-request-number: ${{ steps.createPR.outputs.pull-request-number }} | |
merge-method: rebase |