This is how I want to trigger certain actions with the craft terminal.

It does not work:

# execute Craft commands on remote server
  - name: Execute SSH Craft Commands on remote server
    uses: appleboy/ssh-action@master
      host: ${{ secrets.SSH_HOST }}
      username: ${{ secrets.SSH_USER }}
      key: ${{ secrets.SSH_KEY }}
      script: |
        ./craft project-config/apply

err: bash: ./craft: No such file or directory

If I try

craft project-config/apply

or (as written in some tutorials)

php craft project-config/apply

I get:

out: Could not open input file: craft

What's the correct syntax here? If I do ./craft manually on the server it works just fine.

1 Answer 1


You need to execute the command inside the proeject root. The craft executable isn't available in your $PATH since it's not a globally installed tool, but just a PHP file that's located in the project root.

Those two commands are just two ways to call this executable:

  • php craft runs the craft file with PHP (the version that's linked on the CLI). The craft in this command in just a relative file path in this case.
  • ./craft executes the craft binary directly, the OS knows to execute it with PHP due to the shebang. The ./craft is a relative path to the file.

Due to the way those commands work, they will only function correctly when executed in the project root.

Github actions are executed in the project root by default, but the SSH connection will go to the home directory of the user you're connecting to. This probably isn't the project root, so you either need to use absolute paths or change the working directory as the first command in your action:

cd /path/to/project/root

Put this command as the first part of your script, then it should work correctly.

  • 1
    Nice. In that case I just use cd ${{ secrets.SERVER_LIVE_PATH }}. Thank you
    – KSPR
    Commented Feb 7, 2022 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.