I am using the s3 bucket to serve the frontend app. And I am syncing code in that s3 bucket from the Jenkins server. While building the code in every deployment. Some files get updated some files get renamed, some files get deleted as well in the new folder on the Jenkins server.
Now when we use the s3 sync command on that build folder which was just created and has all the new files created in it. It basically pushes all the code to s3 and doesn't touch the code for example:- the test-123.jpg image which was been pushed in an earlier build. But has been deleted in the recent build.
This kind of file is renamed and all are not getting synced so they are just staying on the server.
May I know which is the ideal way to deal with this kind of issue while pushing the code to S3. My main motive is that I should be able to automatically delete the files which are not getting used or served anymore in the angular app.