update-dependencies #489
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@v4 | |
- name: Setup nodejs version | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
check-latest: true | |
- 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@v7 | |
with: | |
branch: update-dependencies | |
author: Dependency Updater <[email protected]> | |
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' | |
run: gh pr merge --rebase --auto "${{ steps.createPR.outputs.pull-request-number }}" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |