Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions .github/workflows/update-frontend-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Update Frontend Dependencies

on:
schedule:
# Runs at 04:00 UTC every Monday
- cron: '0 4 * * 1'
workflow_dispatch: # Allow manual trigger

jobs:
update-dependencies:
runs-on: ubuntu-latest
strategy:
matrix:
branch: [main, '24.9', '24.8']
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
# Use a token with sufficient permissions to create PRs
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Create branch with current date
run: |
BRANCH_NAME="update-frontend-dependencies-${{ matrix.branch }}-$(date +%Y-%m-%d)"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
git checkout -b $BRANCH_NAME

- name: Run dependency update script
run: |
chmod +x scripts/update-frontend-dependencies.sh
./scripts/update-frontend-dependencies.sh

- name: Check if there are changes
id: check_changes
run: |
if git diff --quiet HEAD~1; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
fi

- name: Push changes
if: steps.check_changes.outputs.has_changes == 'true'
run: |
git push origin ${{ env.BRANCH_NAME }}

- name: Determine update strategy description
if: steps.check_changes.outputs.has_changes == 'true'
run: |
if [ "${{ matrix.branch }}" = "main" ]; then
echo "UPDATE_DESC=All new versions (major, minor, patch)" >> $GITHUB_ENV
else
echo "UPDATE_DESC=Patch releases only" >> $GITHUB_ENV
fi

- name: Create Pull Request
if: steps.check_changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ env.BRANCH_NAME }}
base: ${{ matrix.branch }}
title: "chore: Update frontend dependencies (${{ matrix.branch }})"
body: |
## Automated Frontend Dependency Updates

This PR contains automated updates to frontend dependencies.

### Update Strategy
- Target Branch: ${{ matrix.branch }}
- Updates: ${{ env.UPDATE_DESC }}

### Changes
The dependencies have been updated using `npm-check-updates`.

---
*This PR was automatically created by the update-frontend-dependencies workflow.*
labels: |
dependencies
automated
assignees: |
${{ github.repository_owner }}
31 changes: 0 additions & 31 deletions scripts/update-frontend-depdendencies.sh

This file was deleted.

64 changes: 64 additions & 0 deletions scripts/update-frontend-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

scriptDir=$(dirname $0)
depsFolder=$scriptDir/../flow-server/src/main/resources/com/vaadin/flow/server/frontend/dependencies

# Get current git branch
currentBranch=$(git rev-parse --abbrev-ref HEAD)

# Determine update strategy based on branch
if [ "$currentBranch" = "main" ]; then
updateTarget="latest"
commitMessage="chore: Bump frontend dependencies to latest versions"
else
updateTarget="patch"
commitMessage="chore: Bump frontend dependencies (patch releases only)"
fi

echo "Current branch: $currentBranch"
echo "Update strategy: $updateTarget"

for a in "$depsFolder"/*
do
pushd $a
npx npm-check-updates@18.1.1 -u -t "$updateTarget"
popd
done

# Check for deprecated packages after updates
echo ""
echo "Checking for deprecated packages..."
deprecationFound=false

for a in "$depsFolder"/*
do
pushd $a > /dev/null
folderName=$(basename "$a")

# Run npm-check-updates with --no-deprecated to find deprecated packages
deprecatedOutput=$(npx npm-check-updates@18.1.1 --no-deprecated 2>&1)

# Check if there are any deprecated packages (output will contain package names if found)
if echo "$deprecatedOutput" | grep -q "deprecated"; then
echo "❌ Deprecated packages found in $folderName:"
echo "$deprecatedOutput"
deprecationFound=true
else
echo "✓ No deprecated packages in $folderName"
fi

popd > /dev/null
done

if [ "$deprecationFound" = true ]; then
echo ""
echo "ERROR: Deprecated packages detected!"
echo "On maintenance branches, deprecated packages cannot be auto-updated to major versions."
echo "Please review and update these packages manually."
exit 1
fi

git add "$depsFolder"
git commit -m "$commitMessage"


Loading