Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub Action checkout from specific directory

I am trying to upload a repo to server via ftp on push to master branch. I have it set up and working. However in the repo there is a folder /public. I only want to upload the files in this folder to the server. Not other files or the folder itself. I have tried to set up a working directory for the job but this doesn't seem to do the trick.. any ideas?

 on: 
      push:
        branches:
          - master
    name: 🚀 Deploy website on push
    jobs:
      ftp-web-deploy:
        name: 🎉 Deploy
        runs-on: ubuntu-latest
        defaults:
          run:
            working-directory: ./public
        steps:
        - name: 🚚 Get latest code
          uses: actions/[email protected]
          working-directory: ./public
          with: 
            fetch-depth: 2
        - name: 📂 Sync files
          uses: SamKirkland/[email protected]
          with:
            server: ****
            username: ****
            password: ${{ secrets.prod_ftp_password }}
            server-dir: public_html/

like image 603
Christian Webb Avatar asked Nov 15 '25 10:11

Christian Webb


1 Answers

Checking out only one directory is not possible, but has been requested in the actions/checkout repository before: https://github.com/actions/checkout/issues/483

There's an action to check out specific files, but I haven't tried it and I'm not sure if it does what you want: https://github.com/marketplace/actions/checkout-files

You might want to ask yourself why you're trying to limit the number of files transferred. Is it because you're concerned about traffic? Or because of the input expected in the subsequent action?

If it's the latter, you could also manually "fix" the structure by running some mv and rm commands.

like image 187
rethab Avatar answered Nov 18 '25 15:11

rethab