update dependencies #23
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: | |
push: | |
branches: | |
- main | |
schedule: | |
# 毎週土曜 06:00 JST | |
- cron: '0 21 * * 5' | |
jobs: | |
update-dependencies: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Enable Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16.13.1' | |
- name: Install | |
run : npm install | |
- name: Update dependencies version | |
# --target minor minorバージョンまで上げる | |
# --dep prod devDependenciesは無視 | |
run : npx ncu -u --target minor --dep prod | |
- name: Check diff | |
id: diff | |
run: echo "count=$(git diff --name-only | wc -l)" >> $GITHUB_OUTPUT | |
- name: Install update | |
# 以降は差分がある場合のみ実行 | |
if: steps.diff.outputs.count > 0 | |
run : npm update | |
- name: Commit update | |
# 更新差分を一旦コミット | |
if: steps.diff.outputs.count > 0 | |
run: | | |
git config --global user.email "action@github.com" | |
git config --global user.name "actions-user" | |
git add . | |
git commit -m "bump version of dependencies" | |
- name: Bump version | |
if: steps.diff.outputs.count > 0 | |
run: npm version patch | |
- name: Create Pull Request | |
if: steps.diff.outputs.count > 0 | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
base: 'main' | |
branch: 'auto-update' | |
branch-suffix: 'timestamp' | |
title: 'Bump dependencies version' | |
body: '[npm-check-updates](https://www.npmjs.com/package/npm-check-updates) bump version of dependencies. This PR made by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action' |