How to keep media files inside a git ignored folder on deploy

Hello everybody!
I’ve a plugin installed on wp site (which is based on bedrock), that create a folder with user media files in the root directory (/srv/www/site.com/current/web/user-uploads) . Everything works fine, but deploys. Every time i run the command “ansible-playbook deploy.yml -e “site=site.com env=staging””, all uploaded files from the folder /user-uploads/ are being removed, despite of these two lines in the .gitignore file, which, as i understand, don’t let Git to track or manipulate anything inside the specified folder:
web/user-uploads/*
!web/user-uploads/.gitkeep

Do anybody knows what is the problem? and how to solve that?

See https://github.com/roots/trellis/blob/f948df133c92cf13516c5f0cc00cdde773068e47/roles/deploy/defaults/main.yml#L24-L35 as a reference if you want to get web/user-uploads shared between deploys

(But that plugin shouldn’t be writing to that folder, and should instead be writing to a subfolder in web/app/uploads/)

1 Like