Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exclude option - syntax is wrong in the readme #202

Closed
benwainwright opened this issue Jun 26, 2021 · 11 comments
Closed

exclude option - syntax is wrong in the readme #202

benwainwright opened this issue Jun 26, 2021 · 11 comments

Comments

@benwainwright
Copy link

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

My Action Config

      - name: Upload Files
        uses: SamKirkland/[email protected]
        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
Copy link

Hi!

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

Regards.

@maximilianschmidt
Copy link

maximilianschmidt commented Jun 28, 2021

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
Copy link

vivi90 commented Jun 28, 2021

@SamKirkland Seems to be the same issue like here: #200

@benwainwright
Copy link
Author

@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
Copy link

DemianX0 commented Jul 8, 2021

@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:

return rawValue.replace(/[\[\]]/g, "").trim().split(", ").filter(str => str !== "");

const valueAsArrayDouble = rawValue.split(" - ").map(str => str.trim()).filter(str => str !== "");

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

@SamKirkland SamKirkland changed the title "Sequence is not expected" exclude option - syntax is wrong in the readme Oct 11, 2021
@SamKirkland
Copy link
Owner

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.

ralfgerlich added a commit to modypy/docs that referenced this issue Oct 23, 2021
@SamKirkland
Copy link
Owner

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

To use the beta branch you can use the following:
uses: SamKirkland/[email protected]
Note: This branch will be removed once this change is merged

Any feedback/testing is welcome.

@philharmonie
Copy link

philharmonie commented Nov 17, 2021

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/[email protected]
        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/[email protected] 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
Copy link
Owner

I changed the format in v4.2.0

Please upgrade

@maximilianovanzetti
Copy link

maximilianovanzetti commented Mar 25, 2022

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

I'm using

uses: SamKirkland/[email protected]

...

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
Copy link

Why was exclude removed 4.3.2

I have 1000s of images in a img folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants