SamKirkland / FTP-Deploy-Action

Deploys a GitHub project to a FTP server using GitHub actions
MIT License
3.75k stars 367 forks source link

FTP-Deploy-Action delete ignored files #29

Closed sebastienserre closed 4 years ago

sebastienserre commented 4 years ago

Hello,

I explain the situation:

I'm a French WordPress Developper. I made website with pulgin I download and also plugin I develop my self.

In my project root I ignore folders and files from downloaded plugin through a .gitignore as I only git my own development.

Problem is with the --delete args, file not in Github and present on the host will be deleted...

Solution Your action should check if a .gitignore exists and if so do not delete directory listed in it.

This is my idea, maybe you have a workflow to suggest to me?

SamKirkland commented 4 years ago

This is a good idea!

We could loop over each line in .gitignore and add each as a --exclude-glob setting. Things get a bit complicated when negating globs "!" and when multiple .gitignore files exist in sub-folders.

I'll put this on my backlog, not promises for when/if it will get done.

SamKirkland commented 4 years ago

In the meantime you can probably get a working solution by removing any files you don't want prior to upload. Issue #22

      - name: Clean for Deploy
        run: |
          rm -r node_modules/
          rm -r .github/
          rm -r .git/
          rm .eslintrc.js
          rm .gitignore
          rm .stylelintrc.js
          rm .stylelintignore
          rm yarn.lock
sebastienserre commented 4 years ago

yes but it will delete in my local the files. In local I need them.

SamKirkland commented 4 years ago

yes but it will delete in my local the files. In local I need them.

Do you mean on your local computer? If so github actions are running on a copy of your codebase, nothing you do in an action (delete, add, edit) will affect your local computer files or your github source files. If you run the remove code right before you run this deploy action.

sebastienserre commented 4 years ago

yes on my test a folder with files on FTP and not in Github has been deleted

SamKirkland commented 4 years ago

I see. I'm going to spend some time looking into this, hopefully it'll be in the next version.

Triloworld commented 4 years ago

This is even more tricky as glob pattern of exclude take precedence. For example: --exclude-blob . --exclude-blob ./ --include=no_matter_what Include won't be take to action as doc say: https://lftp.yar.ru/lftp-man.html

I use in other system: https://gist.github.com/Triloworld/f93c2463736660b2541161eb8d63ca8d to ignore from lftp sync some ignore files. This won't work if we have that example:

-X wp-content/* -X !wp-content/mu-plugins/

As "!" isn't proper lftp glob. Glob "*" is only for files. In GitHub Actions is escaped '`' so not working ;/ How I can use env from step before to populate ARGS? If not, how can i choose 2-3 directories to mirror and exclude all other (because --delete remove them now)?

SamKirkland commented 4 years ago

@Triloworld could you try removing the folders you don't want to sync prior to calling the deploy action? See this comment above

Then you can call this action and it will sync the remaining files

Triloworld commented 4 years ago

Using mirror and argument "--delete" then files what don't exist on target device are tagged as old and removed . I write manually long list of defined excluded folders but that is tedious to maintenance.

For example my Wordpress mirror list:

ARGS: --delete --ignore-time --exclude-glob .git/ --exclude-glob .git --skip-noaccess --use-cache -v --exclude-glob wp-admin/ --exclude-glob wp-content/cache/ --exclude-glob wp-content/languages/ --exclude-glob wp-content/mu-plugins/ --exclude-glob wp-content/plugins/ --exclude-glob wp-content/themes/storefront/ --exclude-glob wp-content/themes/twentynineteen/ --exclude-glob wp-content/themes/twentytwenty/ --exclude-glob wp-content/upgrade/ --exclude-glob wp-content/uploads/ --exclude-glob wp-content/advanced-cache.php --exclude-glob wp-content/index.php --exclude-glob wp-includes/ --exclude-glob error_log --exclude-glob index.php --exclude-glob wp- --exclude-glob .ini --exclude-glob *.yaml --exclude-glob xmlrpc.php

They don't exist in git repository, but they are removed with "--delete" method if no "--exclude" was provided. Do you have some example how to use ENV ? I can generate list of arguments, but they aren't recognized as arguments ;/ Maybe we can add configurable file with list of paths to exclude?

SamKirkland commented 4 years ago

V3 has been release with support for ignoring specific files with .git-ftp-ignore which solve your use case.

Breaking change: v3 will only publish tracked (committed) files by default. If your file isn't in source control you will have to add it .git-ftp-include see example

bahi12 commented 2 weeks ago

yes but it will delete in my local the files. In local I need them.

it deletes in in a github container created specifically for this action; your code on local machine is still safe from actions commands.