Mainly, this question is specific to git with Magento 2. I have a working Magento 2 project and I have installed an extension using github repo - https://github.com/Adyen/adyen-magento2.
In my current situation, I have to debug that extension and have to check on my remote server. I have forked that repo and created a patch say for e.g. cc_debug.patch file. Now, I have added that patch to my root directory on local server. Then if I execute patch using git apply --apply --directory=vendor/adyen/module-payment/ cc_debug.patch
it does the trick and modify the files under vendor directory. I pushed the changes over repo and due to deployment script, that file moved to remote server.
Now, I do have only read access over remote server and there is no .git initialized. If I do apply patch over remote server, it will be executed certainly but if I push next time, due to deployment script vendor will be regenerated and changes applied by patch will be lost. Here comes some hook into picture as I know but I am having lack of knowledge regarding hooks.
I assume that I do have to create post-deploy hook in my git local repo such as below:
#!/bin/sh
patchfile = "cc_debug.patch"
patchingdirectory = "vendor/adyen/module-payment/"
if [ -f "$patchfile" ]
then
git apply --apply --directory=$patchingdirectory $patchfile
fi
Now, I can't push that hook to remote repo(not even initialized) so that this solution won't work for me. Or as I know post-update is something specific to remote (correct me if I am wrong) so I am guessing that changes will be executed over remote server due to this hook but if I clone again on another local machine, I do have to create post-deploy patch again, so that isn't the ideal case.
What could be solution for me to apply patch everytime deployment script gets executed? [Note: deployment script is not in my hands as it is executed by webhooks provided by Magento over github. So, I am assuming that there must be some webhook using which I'll have to apply patch and that's again my lack of knowledge.] I am sure someone have the same situation as mine. Please guide me. TIA.
Finally, I found the entry point where I can add my build hooks.. I have modified .magento.app.yaml over root of the Magento 2 directory and added build hook as below:
hooks:
# We run build hooks before your application has been packaged.
build: |
php ./bin/magento magento-cloud:build
patch -p1 --directory=vendor/adyen/module-payment/ < cc_debug.patch #This is the line I have added.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With