Last active
October 16, 2022 19:46
-
-
Save Tjitse-E/7c2367b50eeb6729392a75670c36760a to your computer and use it in GitHub Desktop.
Apply Magento 2.4.4-p2 security patch
This file contains hidden or 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
#!/usr/bin/env bash | |
# exit when any command fails | |
set -e | |
# keep track of the last executed command | |
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG | |
# echo an error message before exiting | |
trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT | |
# Check correct Magento version | |
# n98-magerun2 sys:info | |
magentoVersion=$(cat composer.json | jq -r '.require."magento/product-community-edition"') | |
if [ "$magentoVersion" = "2.4.5-p1" ]; then | |
echo "Found Magento 2.4.4-p1" | |
else | |
echo "This script does not work for Magento version $magentoVersion" | |
echo "Please run this from the root of your Magento project" | |
exit 1 | |
fi | |
composer=$(which composer) | |
php=$(which php) | |
gh=$(which gh) | |
$composer require magento/product-community-edition "2.4.4-p2" --no-update | |
$composer install | |
$php -d memory_limit=3G bin/magento setup:upgrade | |
# Git stuff | |
git checkout CHANGELOG.md pub/ .gitignore | |
git checkout -b "feature/update-to-$magentoVersion" | |
git add composer.json | |
git add composer.lock | |
git add dev/ | |
git add lib/ | |
git commit -n -m "Update to $magentoVersion" | |
git push -u origin "feature/update-to-$magentoVersion" | |
# Create PR | |
prTitle="Update to Magento $magentoVersion" | |
prBody="$(cat << EOF | |
PR body here | |
EOF | |
)" | |
gh pr create --title "$prTitle" --body "$prBody" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment