Search code examples
phplaravelgithubgithub-actionscicd

GitHub Action failed due to workflow is not valid


I am trying to upload my laravel application on shared hosting for auto-deployment. I have integrated the GitHub CI/CD feature with my ftp server. I want to exclude the specific files and folders when github deploys code on FTP server. So for this, I have written then main.yml file. When I push the code on repositories I always get the following error:

The workflow is not valid. .github/workflows/main.yml (Line: 23, Col: 11): A sequence was not expected

But when I remove the exclude option from main.yml file then it work fine but I want to exclude some files and folders.

main.yml

on:
    push:
      branches:
        - staging
name: 🚀 Deploy website on push
jobs:
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    timeout-minutes: 5 # time out after 15 minutes (default is 360 minutes)
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v3
    
    - name: 📂 Sync files
      uses: SamKirkland/[email protected]
      with:
        server: ${{ secrets.ftp_server }}
        username: ${{ secrets.ftp_username }}
        password: ${{ secrets.ftp_password }}
        server-dir: /public_html/admin-test-com/
        exclude:
          - public/**
          - vendor/**
          - crons/**
          - storage/**
          - .github
          - .github/**
          - .env
          - composer.json
          - composer.lock
          - .htaccess

I don't know that what is the issue with this file. Is there any other way that I only upload the changed files instead of all files?


Solution

  • Github inputs cannot be arrays, and please refer to the action's documentation, what you want to do is:

    - name: 📂 Sync files
      uses: SamKirkland/[email protected]
      with:
        server: ${{ secrets.ftp_server }}
        username: ${{ secrets.ftp_username }}
        password: ${{ secrets.ftp_password }}
        server-dir: /public_html/admin-test-com/
        exclude: |
          public/**
          vendor/**
          crons/**
          storage/**
          .github
          .github/**
          .env
          composer.json
          composer.lock
          .htaccess