SamKirkland / FTP-Deploy-Action

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

exclude option - syntax is wrong in the readme #202

Closed benwainwright closed 2 years ago

benwainwright commented 3 years ago

Bug Description "Sequence is not expected" when I add an "exclude" key with multiple entries

My Action Config

      - name: Upload Files
        uses: SamKirkland/FTP-Deploy-Action@4.1.0
        with:
          server-dir: (path on server)
          exclude:
            - "**/node_modules/**"
            - .git/**
            - .cache-loader/**
          log-level: verbose
          server: ${{ secrets.FTP_HOST }}
          username: ${{ secrets.FTP_USERNAME }}
          password: ${{ secrets.FTP_PASSWORD }}

My Action Log

The workflow is not valid. .github/workflows/deploy-to-staging.yaml (Line: 31, Col: 13): A sequence was not expected
juliamenndez commented 3 years ago

Hi!

I was having the same issue. I removed the '-' preceding each item and it worked!

Regards.

maximilianschmidt commented 3 years ago

when removing the - the error is gone but the desired folders aren't excluded anymore, at least for me. 😕

/e so i made it work by typing the exclude-sequence as an array-string like this: exclude: "[**/.git*/**, **/node_modules/**, **/build/, .babelrc, .editorconfig, .eslintrc, .prettierrc, .stylelintrc]"

vivi90 commented 3 years ago

@SamKirkland Seems to be the same issue like here: https://github.com/SamKirkland/FTP-Deploy-Action/issues/200

benwainwright commented 3 years ago

@maximilianschmidt this works for me; you are a star. I'll leave the issue open as the bug as described is still present but I'm gonna unfollow.

DemianX0 commented 3 years ago

@maximilianschmidt Thanks for the solution!

There are two convenient ways to write it, both syntax handled properly by the action. With square brackets - the separator is ,:

        exclude: '[
        , **/.git*/**
        , **/node_modules/**
        , **/build/
        , .babelrc
        , .editorconfig
        , .eslintrc
        , .prettierrc
        , .stylelintrc
        ]'

Without square brackets - note the separator is -:

        exclude: '
        - **/.git*/**
        - **/node_modules/**
        - **/build/
        - .babelrc
        - .editorconfig
        - .eslintrc
        - .prettierrc
        - .stylelintrc
        '

GitHub actions API does not handle yaml lists, only strings, thus the need to pass a string which is then split into individual globs. The function that parses it: https://github.com/SamKirkland/FTP-Deploy-Action/blob/65c6a8f943bbf04faf9b59520a103318b418952e/src/parse.ts#L102 https://github.com/SamKirkland/FTP-Deploy-Action/blob/65c6a8f943bbf04faf9b59520a103318b418952e/src/parse.ts#L106

README.md could be updated to reflect one of these syntaxes.

SamKirkland commented 2 years ago

I'm pretty sure git changed how those were coming back, it worked in all my test cases until one day... it stopped.

Anyway, it looks like git added a new getMultilineInput option.

Lot of other actions have started using this format for lists of params (first pipe is needed to indicate its multiline)

        exclude: |
          **/.git*
          **/.git*/**
          **/node_modules/**
          fileToExclude.txt

Thoughts? I'd like to drop support for [] and - with this change.

SamKirkland commented 2 years ago

I have a beta branch deployed that uses the new format.

To use the beta branch you can use the following: uses: SamKirkland/FTP-Deploy-Action@v4.2.0-beta Note: This branch will be removed once this change is merged

Any feedback/testing is welcome.

philharmonie commented 2 years ago

What is the latest way of working code in the master? I got my script but is not excluding a single line:

on:
  push:
    branches:
      - testserver
name: 🚀 Deploy app to test server
jobs:
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
      - name: 🚚 Get latest code
        uses: actions/checkout@v2

      - name: 📂 Sync files
        uses: SamKirkland/FTP-Deploy-Action@4.1.0
        with:
          server: ftp.myserver.com
          username: d0123456
          password: ${{ secrets.ftp_password }}
          exclude: |
            **/node_modules/**
            **/.git
            **/.github
            ./tests/**
            ./vendor/**
            ./writeable/**

Same for

          exclude: 
            - **/node_modules/**
            - **/.git
            - **/.github
            - ./tests/**
            - ./vendor/**
            - ./writeable/**

I tested uses: SamKirkland/FTP-Deploy-Action@v4.2.0-beta as well with:

exclude: |
            **/node_modules/**
            **/.git
            **/.github
            tests/**
            vendor/**
            writeable/**

It is not excluding the files either.

Btw. in the first two tries, I tried both, ./vendor/** and vendor/**

SamKirkland commented 2 years ago

I changed the format in v4.2.0

Please upgrade

maximilianovanzetti commented 2 years ago

What is the correct syntax to exclude all files in a folder?

I'm using

uses: SamKirkland/FTP-Deploy-Action@4.3.0

...

exclude: |
          rt/app/logs/
          rt/app/logs/*
          rt/app/logs
          rt/app/logs/** 
          **/.git*
          **/.git*/**
          **/node_modules/**

None of the combinations work for me.

I have also tried with:

          **/rt/app/logs.....
          ./rt/app/logs...
          **rt/app/logs....
Ben1nBlack commented 1 year ago

Why was exclude removed 4.3.2

I have 1000s of images in a img folder