From d6ddf4ed3a4e0393848f1b78bd8ad2abbf1d7421 Mon Sep 17 00:00:00 2001 From: Adhun Anand Date: Wed, 4 Dec 2024 22:09:39 +0530 Subject: [PATCH] Create deploy.yml --- .github/workflows/deploy.yml | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..56f0d779 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,60 @@ +name: Deploy WordPress Plugin + +env: + PHP_VERSION: '8.1' + NODE_VERSION: '16' + PLUGIN_NAME: 'wp-job-openings' + +on: + push: + branches: + - staging + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.PHP_VERSION }} + + - name: Cache Composer packages + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install NPM Dependencies + run: npm ci + + - name: Install Composer Dependencies + if: hashFiles('composer.json') + run: composer install --no-dev --optimize-autoloader + + - name: Build Assets + run: npm run build + + - name: Install SSH Key + uses: shimataro/ssh-key-action@v2 + with: + key: ${{ secrets.SSH_PRIVATE_KEY }} + known_hosts: unnecessary + + - name: Adding Known Hosts + run: ssh-keyscan -p 22 -H ${{ secrets.REMOTE_HOST }} >> ~/.ssh/known_hosts + + - name: Deploy with rsync + run: rsync -avz -e "ssh -p 22" --exclude='.git' --exclude='.github' --exclude='node_modules' --exclude='.gitignore' --exclude='.eslintrc' --exclude='gulpfile.js' --exclude='package.json' --exclude='package-lock.json' --exclude='composer.json' --exclude='composer.lock' --exclude='.eslintignore' --exclude='.browserslistrc' . ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }}:${{ secrets.REMOTE_PATH }}/wp-content/plugins/${{ env.PLUGIN_NAME }}