Skip to content

Check for Yarn dependency updates #13

Check for Yarn dependency updates

Check for Yarn dependency updates #13

name: Check for Yarn dependency updates
on:
schedule:
# Runs every 2 weeks (Monday at 00:00 UTC)
- cron: '0 0 */14 * *'
workflow_dispatch: # Optional: Allow manual trigger
jobs:
dependency-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install scripts dependencies
run: |
cd .github/scripts
npm install
- name: Install project dependencies
run: yarn install
- name: Check for outdated dependencies
id: outdated
run: |
yarn outdated --json > outdated.json || true
- name: Determine if any dependencies are outdated
id: check_outdated
run: |
if [ -s outdated.json ]; then
echo "outdated=true" >> $GITHUB_ENV
else
echo "outdated=false" >> $GITHUB_ENV
fi
- name: Create issue with outdated dependencies
if: env.outdated == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
node .github/scripts/create-issue.js
- name: Create branch and update dependencies
if: env.outdated == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b dependency-updates
yarn upgrade --latest --minor
yarn upgrade --latest --patch
git commit -am "chore: upgrade minor and patch dependencies"
git push origin dependency-updates
- name: Create pull request linking to issue
if: env.outdated == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
node .github/scripts/create-pull-request.js