How to upload Wordpress theme files from github subdirectory to server with yml and rsync?

Viewed 21

I have initialized the git repository in main Wordpress directory. I pushed my theme files on github and I am trying to rsync files with my web server using github actions.

my repo screen

For this purpose I created .yml file below:

# This is a basic workflow to help you get started with Actions

name: Deployment

# Controls when the workflow will run on:   # Triggers the workflow on push or pull request events but only for the "main" branch   push:
    branches: [ "main" ]

  # Allows you to run this workflow manually from the Actions tab   workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs:   # This workflow contains a single job called "build"   deploy:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3

      - name: Sync
        env:
          dest: 'path/public_html/wp-content/themes/webpack'
        run: |
          echo "${{secrets.DEPLOY_KEY}}" > deploy_key
          chmod 600 ./deploy_key
          rsync -chav --delete \
            -e 'ssh -i ./deploy_key -o StrictHostKeyChecking=no' \
            --exclude /deploy_key \
            --exclude /.git/ \
            --exclude /.gitignore \
            --exclude /.github/ \
            --exclude /node_modules/ \
            ./ ${{env.dest}}

Please tell me guys how I can rsync Github repo subfolder /wp-content/themes/webpack with my theme path on web server 'path/public_html/wp-content/themes/webpack'? At this point I will receive nested folders on web server: path/public_html/wp-content/themes/webpack/wp-content/themes/webpack

1 Answers

Okay, solved.

Just need to modify the last line:

./wp-content/themes/webpack/ ${{env.dest}}
Related